Zelda Classic Coverage Report


Directory: src/
File: src/zc/hero.cpp
Date: 2023-05-31 17:35:38
Exec Total Coverage
Lines: 12691 19619 64.7%
Functions: 262 339 77.3%
Branches: 10910 21813 50.0%

Line Branch Exec Source
1 //--------------------------------------------------------
2 //--------------------------------------------------------
3 //--------------------------------------------------------
4 // Zelda Classic
5 // by Jeremy Craner, 1999-2000
6 //
7 // hero.cpp
8 //
9 // Hero's class: HeroClass
10 // Handles a lot of game play stuff as well as Hero's
11 // movement, attacking, etc.
12 //
13 //--------------------------------------------------------
14
15 #include <string.h>
16 #include <set>
17
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 #include <stdio.h>
18
19 #include "zc/hero.h"
20 #include "zc/guys.h"
21 #include "subscr.h"
22 #include "zc/zc_subscr.h"
23 #include "zc/decorations.h"
24 #include "gamedata.h"
25 #include "zc/zc_custom.h"
26 #include "zc/title.h"
27 #include "zc/ffscript.h"
28 #include "drawing.h"
29 #include "zc/combos.h"
30 #include "base/zc_math.h"
31 #include "user_object.h"
32 #include "slopes.h"
33 extern FFScript FFCore;
34 extern word combo_doscript[176];
35 extern byte itemscriptInitialised[256];
36 extern HeroClass Hero;
37 extern ZModule zcm;
38 extern zcmodule moduledata;
39 extern refInfo playerScriptData;
40 #include "zscriptversion.h"
41 #include "particles.h"
42 #include <fmt/format.h>
43 #include "zc/render.h"
44
45 extern refInfo itemScriptData[256];
46 extern refInfo itemCollectScriptData[256];
47 extern int32_t item_stack[256][MAX_SCRIPT_REGISTERS];
48 extern int32_t item_collect_stack[256][MAX_SCRIPT_REGISTERS];
49 extern refInfo *ri; //= NULL;
50 extern int32_t(*stack)[MAX_SCRIPT_REGISTERS];
51 extern byte dmapscriptInitialised;
52 extern word item_doscript[256];
53 extern word item_collect_doscript[256];
54 extern portal mirror_portal;
55 using std::set;
56
57 extern int32_t skipcont;
58
59 extern int32_t draw_screen_clip_rect_x1;
60 extern int32_t draw_screen_clip_rect_x2;
61 extern int32_t draw_screen_clip_rect_y1;
62 extern int32_t draw_screen_clip_rect_y2;
63 extern word global_wait;
64 extern bool player_waitdraw;
65 extern bool dmap_waitdraw;
66 extern bool passive_subscreen_waitdraw;
67 extern bool active_subscreen_waitdraw;
68
69 int32_t hero_count = -1;
70 int32_t hero_animation_speed = 1; //lower is faster animation
71 static int32_t z3step = 2;
72 33 static zfix hero_newstep(1.5);
73 33 static zfix hero_newstep_diag(1.5);
74 bool did_scripta=false;
75 bool did_scriptb=false;
76 bool did_scriptl=false;
77 byte lshift = 0;
78 int32_t dowpn = -1;
79 int32_t directItem = -1; //Is set if Hero is currently using an item directly
80 int32_t directItemA = -1;
81 int32_t directItemB = -1;
82 int32_t directItemX = -1;
83 int32_t directItemY = -1;
84 int32_t directWpn = -1;
85 int32_t whistleitem=-1;
86 extern word g_doscript;
87 extern word player_doscript;
88 extern word dmap_doscript;
89 extern word passive_subscreen_doscript;
90 extern int32_t script_hero_cset;
91
92 void playLevelMusic();
93
94 extern particle_list particles;
95
96 byte lsteps[8] = { 1, 1, 2, 1, 1, 2, 1, 1 };
97
98 #define CANFORCEFACEUP (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0 && dir!=up && (action==walking || action==none))
99 #define NO_GRIDLOCK (get_bit(quest_rules, qr_DISABLE_4WAY_GRIDLOCK)||get_bit(quest_rules, qr_NEW_HERO_MOVEMENT2))
100 #define SWITCHBLOCK_STATE (switchblock_z<0?switchblock_z:(switchblock_z+z+fakez < 0 ? zslongToFix(2147483647) : switchblock_z+z+fakez))
101 #define FIXED_Z3_ANIMATION ((zinit.heroAnimationStyle==las_zelda3||zinit.heroAnimationStyle==las_zelda3slow)&&!get_bit(quest_rules,qr_BROKEN_Z3_ANIMATION))
102
103 1833 bool item_error()
104 {
105
2/2
✓ Branch 0 taken 1809 times.
✓ Branch 1 taken 24 times.
1833 if(QMisc.miscsfx[sfxERROR])
106 1809 sfx(QMisc.miscsfx[sfxERROR]);
107 1833 return false;
108 }
109 17551148 static inline bool on_sideview_slope(int32_t x, int32_t y, int32_t oldx, int32_t oldy)
110 {
111
2/2
✓ Branch 0 taken 19493 times.
✓ Branch 1 taken 17531655 times.
17551148 if(check_new_slope(x, y+1, 16, 16, oldx, oldy) < 0) return true;
112 17531655 return false;
113 17551148 }
114
115 5860160 static inline bool platform_fallthrough(bool doslopecheck = true)
116 {
117
5/6
✓ Branch 0 taken 5860160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5848334 times.
✓ Branch 3 taken 11826 times.
✓ Branch 4 taken 5842618 times.
✓ Branch 5 taken 5716 times.
16103262 return (doslopecheck && !on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0))
118
2/2
✓ Branch 0 taken 742562 times.
✓ Branch 1 taken 730736 times.
5860160 || (getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0) && get_bit(quest_rules,qr_DOWN_FALL_THROUGH_SIDEVIEW_PLATFORMS))
119
6/6
✓ Branch 0 taken 4384902 times.
✓ Branch 1 taken 5127464 times.
✓ Branch 2 taken 339572 times.
✓ Branch 3 taken 5518628 times.
✓ Branch 4 taken 312189 times.
✓ Branch 5 taken 27383 times.
1473298 || (Hero.jumping < 0 && getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0) && get_bit(quest_rules,qr_DOWNJUMP_FALL_THROUGH_SIDEVIEW_PLATFORMS));
120 }
121
122 static inline bool on_sideview_solid(int32_t x, int32_t y, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
123 {
124 if(slopesmisc != 1 && check_slope(x, y+1, 16, 16, (slopesmisc == 3)) < 0) return true;
125 if(slopesmisc == 2) return false;
126 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
127 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
128 if (platform_fallthrough() && !ignoreFallthrough) return false;
129 if(slopesmisc != 1 && check_slope(x, y+1, 16, 16) < 0) return true;
130 if (y%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
131 return true;
132 return false;
133 }
134
135 8543923 static inline bool on_sideview_solid_oldpos(int32_t x, int32_t y, int32_t oldx, int32_t oldy, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
136 {
137
4/4
✓ Branch 0 taken 1861454 times.
✓ Branch 1 taken 6682469 times.
✓ Branch 2 taken 1800745 times.
✓ Branch 3 taken 60709 times.
8543923 if(slopesmisc != 1 && check_new_slope(x, y+1, 16, 16, oldx, oldy, (slopesmisc == 3)) < 0) return true;
138
2/2
✓ Branch 0 taken 127631 times.
✓ Branch 1 taken 8355583 times.
8483214 if(slopesmisc == 2) return false;
139
4/4
✓ Branch 0 taken 6032688 times.
✓ Branch 1 taken 2322895 times.
✓ Branch 2 taken 171854 times.
✓ Branch 3 taken 5860834 times.
8355583 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
140
6/6
✓ Branch 0 taken 52031 times.
✓ Branch 1 taken 5808803 times.
✓ Branch 2 taken 2120 times.
✓ Branch 3 taken 49911 times.
✓ Branch 4 taken 1445 times.
✓ Branch 5 taken 675 times.
5860834 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
141
4/4
✓ Branch 0 taken 2011 times.
✓ Branch 1 taken 5858148 times.
✓ Branch 2 taken 298 times.
✓ Branch 3 taken 1713 times.
5860159 if (platform_fallthrough() && !ignoreFallthrough) return false;
142
4/4
✓ Branch 0 taken 767055 times.
✓ Branch 1 taken 5091391 times.
✓ Branch 2 taken 764284 times.
✓ Branch 3 taken 2771 times.
5858446 if (slopesmisc != 1 && check_new_slope(x, y + 1, 16, 16, oldx, oldy) < 0) return true;
143
6/6
✓ Branch 0 taken 1702741 times.
✓ Branch 1 taken 4152934 times.
✓ Branch 2 taken 1679759 times.
✓ Branch 3 taken 22982 times.
✓ Branch 4 taken 262 times.
✓ Branch 5 taken 1679497 times.
5855675 if (y%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
144 23244 return true;
145 5832431 return false;
146 8543923 }
147
148
149 18549832 bool usingActiveShield(int32_t itmid)
150 {
151
2/2
✓ Branch 0 taken 2579304 times.
✓ Branch 1 taken 15970528 times.
18549832 switch(Hero.action) //filter allowed actions
152 {
153 case none: case walking: case rafting:
154 case gothit: case swimhit:
155 15970528 break;
156 2579304 default: return false;
157 }
158
3/4
✓ Branch 0 taken 942 times.
✓ Branch 1 taken 15969586 times.
✓ Branch 2 taken 942 times.
✗ Branch 3 not taken.
15970528 if(Hero.lift_wpn && (Hero.liftflags&LIFTFL_DIS_SHIELD)) return false;
159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15970528 times.
15970528 if(itmid < 0)
160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15970528 times.
15970528 itmid = (Hero.active_shield_id < 0
161 15970528 ? current_item_id(itype_shield,true,true) : Hero.active_shield_id);
162
2/2
✓ Branch 0 taken 14493195 times.
✓ Branch 1 taken 1477333 times.
15970528 if(itmid < 0) return false;
163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14493195 times.
14493195 if(item_disabled(itmid)) return false;
164
1/2
✓ Branch 0 taken 14493195 times.
✗ Branch 1 not taken.
14493195 if(!checkitem_jinx(itmid)) return false;
165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14493195 times.
14493195 if(!(itemsbuf[itmid].flags & ITEM_FLAG9)) return false;
166 if(!isItmPressed(itmid)) return false;
167 return (checkbunny(itmid) && checkmagiccost(itmid));
168 18549832 }
169 11501771 int32_t getCurrentShield(bool requireActive)
170 {
171
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11501771 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11501771 if(Hero.active_shield_id > -1 && usingActiveShield(Hero.active_shield_id))
172 return Hero.active_shield_id;
173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11501771 times.
11501771 if(!requireActive) return current_item_id(itype_shield);
174 return -1;
175 11501771 }
176 91548 int32_t getCurrentActiveShield()
177 {
178 91548 int32_t id = Hero.active_shield_id;
179
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 91548 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
91548 if(id > -1 && usingActiveShield(id))
180 return id;
181 91548 return -1;
182 91548 }
183 6419576 int32_t refreshActiveShield()
184 {
185 6419576 int32_t id = -1;
186
2/2
✓ Branch 0 taken 6241134 times.
✓ Branch 1 taken 178442 times.
6419576 if(DrunkcBbtn())
187 {
188 178442 itemdata const& dat = itemsbuf[Bwpn&0xFFF];
189
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 178442 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
178442 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
190 {
191 id = Bwpn&0xFFF;
192 }
193 178442 }
194
3/4
✓ Branch 0 taken 6419576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5864125 times.
✓ Branch 3 taken 555451 times.
6419576 if(id < 0 && DrunkcAbtn())
195 {
196 555451 itemdata const& dat = itemsbuf[Awpn&0xFFF];
197
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 555451 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
555451 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
198 {
199 id = Awpn&0xFFF;
200 }
201 555451 }
202
3/4
✓ Branch 0 taken 6419576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6419504 times.
✓ Branch 3 taken 72 times.
6419576 if(id < 0 && DrunkcEx1btn())
203 {
204 72 itemdata const& dat = itemsbuf[Xwpn&0xFFF];
205
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
72 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
206 {
207 id = Xwpn&0xFFF;
208 }
209 72 }
210
3/4
✓ Branch 0 taken 6419576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6418419 times.
✓ Branch 3 taken 1157 times.
6419576 if(id < 0 && DrunkcEx2btn())
211 {
212 1157 itemdata const& dat = itemsbuf[Ywpn&0xFFF];
213
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1157 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1157 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
214 {
215 id = Ywpn&0xFFF;
216 }
217 1157 }
218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6419576 times.
6419576 if(!usingActiveShield(id))
219 6419576 return -1;
220 return id;
221 6419576 }
222 static bool is_immobile()
223 {
224 if(!get_bit(quest_rules, qr_NEW_HERO_MOVEMENT))
225 return false;
226 zfix rate(Hero.steprate);
227 int32_t shieldid = getCurrentActiveShield();
228 if(shieldid > -1)
229 {
230 itemdata const& shield = itemsbuf[shieldid];
231 if(shield.flags & ITEM_FLAG10) //Change Speed flag
232 {
233 zfix perc = shield.misc7;
234 perc /= 100;
235 if(perc < 0)
236 perc = (perc*-1)+1;
237 rate = (rate * perc) + shield.misc8;
238 }
239 }
240 return rate != 0;
241 }
242
243 12895882 bool nomove_action(int action)
244 {
245
2/2
✓ Branch 0 taken 12449928 times.
✓ Branch 1 taken 445954 times.
12895882 switch(action)
246 {
247 case gothit:
248 case drowning:
249 case lavadrowning:
250 case sidedrowning:
251 case falling:
252 case freeze:
253 case sideswimfreeze:
254 case scrolling:
255 case casting:
256 case sideswimcasting:
257 case landhold1:
258 case landhold2:
259 case waterhold1:
260 case waterhold2:
261 case sidewaterhold1:
262 case sidewaterhold2:
263 case hopping:
264 case inwind:
265 445954 return true;
266 }
267 12449928 return false;
268 12895882 }
269
270 6610735 bool HeroClass::isStanding(bool forJump)
271 {
272
3/4
✓ Branch 0 taken 6606569 times.
✓ Branch 1 taken 4166 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6606569 times.
6610735 if(z || fakez) return false;
273
4/4
✓ Branch 0 taken 274226 times.
✓ Branch 1 taken 6332343 times.
✓ Branch 2 taken 640 times.
✓ Branch 3 taken 130319 times.
6737528 if(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y)
274
4/6
✓ Branch 0 taken 130959 times.
✓ Branch 1 taken 143267 times.
✓ Branch 2 taken 130959 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 130959 times.
✗ Branch 5 not taken.
274226 && !ladderx && !laddery && !getOnSideviewLadder())
275 130319 return false;
276
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 6476214 times.
6476250 if(hoverclk) return false;
277
2/2
✓ Branch 0 taken 221213 times.
✓ Branch 1 taken 6255001 times.
6476214 if(nomove_action(action)) return false;
278 6255001 int32_t val = check_pitslide();
279
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 6254990 times.
6255001 if(val == -2) return false;
280
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 6254975 times.
6254990 if(val == -1) return true;
281 15 return forJump;
282 6610735 }
283 29077 bool HeroClass::isLifting()
284 {
285
2/2
✓ Branch 0 taken 502 times.
✓ Branch 1 taken 28575 times.
29077 if(lift_wpn) return true;
286 28575 return false;
287 29077 }
288 11 void HeroClass::set_liftflags(int liftid)
289 {
290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(unsigned(liftid) >= MAXITEMS)
291 return;
292 11 itemdata const& itm = itemsbuf[liftid];
293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 SETFLAG(liftflags, LIFTFL_DIS_SHIELD, itm.flags & ITEM_FLAG3);
294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 SETFLAG(liftflags, LIFTFL_DIS_ITEMS, itm.flags & ITEM_FLAG4);
295 11 }
296
297 46401 void HeroClass::set_respawn_point(bool setwarp)
298 {
299
2/2
✓ Branch 0 taken 38388 times.
✓ Branch 1 taken 8013 times.
46401 if(setwarp)
300 {
301 8013 warpx = x;
302 8013 warpy = y;
303 8013 raftwarpx = x;
304 8013 raftwarpy = y;
305 8013 }
306
2/2
✓ Branch 0 taken 18701 times.
✓ Branch 1 taken 27700 times.
46401 if(!get_bit(quest_rules,qr_OLD_RESPAWN_POINTS))
307 {
308
2/2
✓ Branch 0 taken 26419 times.
✓ Branch 1 taken 1281 times.
27700 switch(action)
309 {
310 case none: case walking:
311 26419 break;
312 default:
313 1281 return; //Not a 'safe action'
314 }
315
5/6
✓ Branch 0 taken 26055 times.
✓ Branch 1 taken 364 times.
✓ Branch 2 taken 26055 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19 times.
✓ Branch 5 taken 26036 times.
26419 if(z > 0 || fakez > 0 || hoverclk) return; //in air
316
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 26035 times.
26036 if(check_pitslide(true) != -1) return; //On a pit
317
318 { //Check water
319 26035 int32_t water = 0;
320 26035 int32_t types[4] = {0};
321 26035 int32_t x1 = x+4, x2 = x+11,
322 26035 y1 = y+9, y2 = y+15;
323
1/2
✓ Branch 0 taken 26035 times.
✗ Branch 1 not taken.
26035 if (get_bit(quest_rules, qr_SMARTER_WATER))
324 {
325
3/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 26010 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
26036 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
326
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
327
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
328 1 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
329 26035 }
330 else
331 {
332 types[0] = COMBOTYPE(x1,y1);
333
334 if(MAPFFCOMBO(x1,y1))
335 types[0] = FFCOMBOTYPE(x1,y1);
336
337 types[1] = COMBOTYPE(x1,y2);
338
339 if(MAPFFCOMBO(x1,y2))
340 types[1] = FFCOMBOTYPE(x1,y2);
341
342 types[2] = COMBOTYPE(x2,y1);
343
344 if(MAPFFCOMBO(x2,y1))
345 types[2] = FFCOMBOTYPE(x2,y1);
346
347 types[3] = COMBOTYPE(x2,y2);
348
349 if(MAPFFCOMBO(x2,y2))
350 types[3] = FFCOMBOTYPE(x2,y2);
351
352 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
353 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
354 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
355
356 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
357 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
358 water = typec;
359 }
360
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 26034 times.
26035 if(water > 0)
361 {
362 1 return;
363 }
364 } //End check water
365
366 130170 int poses[4] = {
367 26034 COMBOPOS(x,y+(bigHitbox?0:8)),
368 26034 COMBOPOS(x,y+15),
369 26034 COMBOPOS(x+15,y+(bigHitbox?0:8)),
370 26034 COMBOPOS(x+15,y+15)
371 };
372
2/2
✓ Branch 0 taken 103229 times.
✓ Branch 1 taken 25705 times.
128934 for(auto pos : poses)
373 {
374
2/2
✓ Branch 0 taken 102900 times.
✓ Branch 1 taken 329 times.
103229 if(HASFLAG_ANY(mfUNSAFEGROUND, pos)) //"Unsafe Ground" flag touching the player
375 329 return;
376 }
377 25705 }
378 44406 respawn_x = x;
379 44406 respawn_y = y;
380 44406 respawn_scr = currscr;
381 44406 respawn_dmap = currdmap;
382 46401 }
383
384 13 void HeroClass::go_respawn_point()
385 {
386 13 x = respawn_x;
387 13 y = respawn_y;
388 13 handle_portal_prox(&mirror_portal);
389
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 portals.forEach([&](sprite& p)
390 {
391 handle_portal_prox((portal*)&p);
392 return false;
393 });
394 13 warpx=x;
395 13 warpy=y;
396 13 raftwarpx = x;
397 13 raftwarpy = y;
398 13 trySideviewLadder(); //Cling to ladder automatically
399
400
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
13 if(get_bit(quest_rules, qr_OLD_RESPAWN_POINTS))
401 12 return; //No cross-screen return
402
403
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(currdmap != respawn_dmap || currscr != respawn_scr)
404 {
405 FFCore.warp_player(wtIWARP, respawn_dmap, respawn_scr,
406 -1, -1, 0, 0, warpFlagNOSTEPFORWARD|warpFlagDONTKILLMUSIC, -1);
407 }
408 13 }
409
410 12232 void HeroClass::trySideviewLadder()
411 {
412
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12232 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12232 if(canSideviewLadder() && !on_sideview_solid_oldpos(x,y,old_x,old_y))
413 setOnSideviewLadder(true);
414 12232 }
415
416 29377580 bool HeroClass::can_pitfall(bool ignore_hover)
417 {
418
27/30
✓ Branch 0 taken 28740030 times.
✓ Branch 1 taken 637550 times.
✓ Branch 2 taken 28547463 times.
✓ Branch 3 taken 192567 times.
✓ Branch 4 taken 28540169 times.
✓ Branch 5 taken 7294 times.
✓ Branch 6 taken 28540169 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 28540115 times.
✓ Branch 9 taken 54 times.
✓ Branch 10 taken 28540115 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 70 times.
✓ Branch 13 taken 28540045 times.
✓ Branch 14 taken 28530768 times.
✓ Branch 15 taken 9347 times.
✓ Branch 16 taken 28529901 times.
✓ Branch 17 taken 867 times.
✓ Branch 18 taken 28528655 times.
✓ Branch 19 taken 1246 times.
✓ Branch 20 taken 28448415 times.
✓ Branch 21 taken 80240 times.
✓ Branch 22 taken 28012006 times.
✓ Branch 23 taken 436409 times.
✓ Branch 24 taken 28011726 times.
✓ Branch 25 taken 280 times.
✓ Branch 26 taken 28011726 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 1280 times.
✓ Branch 29 taken 28010446 times.
29377580 return (!(isSideViewGravity()||action==rafting||z>0||fakez>0||fall<0||fakefall<0||(hoverclk && !ignore_hover)||inlikelike||inwallm||pull_hero||toogam||(ladderx||laddery)||getOnSideviewLadder()||drownclk||!(moveflags & FLAG_CAN_PITFALL)));
419 }
420
421 3705513 int32_t HeroClass::DrunkClock()
422 {
423 3705513 return drunkclk;
424 }
425 void HeroClass::setDrunkClock(int32_t newdrunkclk)
426 {
427 drunkclk=newdrunkclk;
428 }
429
430 int32_t HeroClass::StunClock()
431 {
432 return lstunclock;
433 }
434 void HeroClass::setStunClock(int32_t v)
435 {
436 lstunclock=v;
437 }
438
439 98523392 int32_t HeroClass::BunnyClock()
440 {
441 98523392 return lbunnyclock;
442 }
443 void HeroClass::setBunnyClock(int32_t v)
444 {
445 lbunnyclock=v;
446 }
447
448
11/22
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 33 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 33 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 33 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 33 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 33 times.
✗ Branch 21 not taken.
99 HeroClass::HeroClass() : sprite()
449 66 {
450 33 lift_wpn = nullptr;
451
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 init();
452 33 }
453
454 //2.6
455
456 //Stop the subscreen from falling. -Z
457
458 717 bool HeroClass::stopSubscreenFalling(){
459 717 return preventsubscreenfalling;
460 }
461
462 void HeroClass::stopSubscreenFalling(bool v){
463 preventsubscreenfalling = v;
464 }
465
466
467 //Set the button items by brute force
468
469 void HeroClass::setAButtonItem(int32_t itmslot){
470 game->awpn = itmslot;
471 }
472
473 void HeroClass::setBButtonItem(int32_t itmslot){
474 game->bwpn = itmslot;
475 }
476
477 6419923 void HeroClass::ClearhitHeroUIDs()
478 { //Why the flidd doesn't this work?! Clearing this to 0 in a way that doesn't demolish script access is impossible. -Z
479 //All I want, is to clear it at the end of a frame, or at the start of a frame, so that if it changes to non-0
480 //that a script can read it before Waitdraw(). --I want it to go stale at the end of a frame.
481 //I suppose I will need to do this inside the script engine, and not the game_loop() ? -Z
482 //THis started out as a simple clear to 0 of lastHitBy[n], but that did not work:
483 //I added the second element to this, so that I could store the frame on which the hit is recorded, and
484 //clear it on the next frame, but that had the SAME outcome.
485 //Where and how can I clear a value at the end of every frame, so that:
486 // 1. If set by internal mecanics, it has its value that you can read by script, before waitdraw--this part works at present.
487 // 2. FFCs can read it before Waitframe. --same.
488 // 3. After Waitframe(), it is wiped by the ZC Engine to 0. --I cannot get this to happen without breaking 1 and 2.
489
2/2
✓ Branch 0 taken 109138691 times.
✓ Branch 1 taken 6419923 times.
115558614 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ )
490 {
491 /*
492 if ( lastHitBy[q][1] == (frame-1) ) //Verify if this is needed at all now.
493 {
494 //Z_scripterrlog("frame is: %d\n", frame);
495 //Z_scripterrlog("Player->HitBy frame is: %d\n", lastHitBy[q][1]);
496 lastHitBy[q][0] = 0;
497 }
498 */
499 109138691 lastHitBy[q][0] = 0;
500 109138691 }
501 6419923 }
502
503 34288 void HeroClass::sethitHeroUID(int32_t type, int32_t screen_index)
504 {
505 34288 lastHitBy[type][0] = screen_index;
506 34288 }
507
508 2929 int32_t HeroClass::gethitHeroUID(int32_t type)
509 {
510 2929 return lastHitBy[type][0];
511 }
512
513 void HeroClass::set_defence(int32_t type, int32_t v)
514 {
515 defence[type] = v;
516 }
517
518 int32_t HeroClass::get_defence(int32_t type)
519 {
520 return defence[type];
521 }
522
523
524 //Set Hero;s hurt sfx
525 void HeroClass::setHurtSFX(int32_t sfx)
526 {
527 QMisc.miscsfx[sfxHURTPLAYER] = sfx;
528 }
529 6878 int32_t HeroClass::getHurtSFX()
530 {
531 6878 return QMisc.miscsfx[sfxHURTPLAYER];
532 }
533
534 bool HeroClass::getDiagMove()
535 {
536 return diagonalMovement;
537 }
538 void HeroClass::setDiagMove(bool newdiag)
539 {
540 diagonalMovement=newdiag;
541 }
542 9024 bool HeroClass::getBigHitbox()
543 {
544 9024 return bigHitbox;
545 }
546 333 void HeroClass::setBigHitbox(bool newbigHitbox)
547 {
548 333 bigHitbox=newbigHitbox;
549 333 syofs = bigHitbox?0:8;
550 333 sysz_ofs = bigHitbox?0:-8;
551 333 }
552 5424 int32_t HeroClass::getStepRate()
553 {
554 5424 return steprate;
555 }
556 void HeroClass::setStepRate(int32_t newrate)
557 {
558 steprate = newrate;
559 }
560 int32_t HeroClass::getSwimUpRate()
561 {
562 return game->get_sideswim_up();
563 }
564 void HeroClass::setSwimUpRate(int32_t newrate)
565 {
566 game->set_sideswim_up(newrate);
567 }
568 int32_t HeroClass::getSwimSideRate()
569 {
570 return game->get_sideswim_side();
571 }
572 void HeroClass::setSwimSideRate(int32_t newrate)
573 {
574 game->set_sideswim_side(newrate);
575 }
576 int32_t HeroClass::getSwimDownRate()
577 {
578 return game->get_sideswim_down();
579 }
580 void HeroClass::setSwimDownRate(int32_t newrate)
581 {
582 game->set_sideswim_down(newrate);
583 }
584
585
586 //void HeroClass::herostep() { lstep = lstep<(BSZ?27:11) ? lstep+1 : 0; }
587 4633242 void HeroClass::herostep()
588 {
589
2/2
✓ Branch 0 taken 4244028 times.
✓ Branch 1 taken 389214 times.
4633242 lstep = lstep<((zinit.heroAnimationStyle==las_bszelda)?27:11) ? lstep+1 : 0;
590 //need to run all global/hero/dmap scripts here?
591 4633242 }
592
593 74723 bool is_moving()
594 {
595
6/6
✓ Branch 0 taken 60449 times.
✓ Branch 1 taken 14274 times.
✓ Branch 2 taken 45245 times.
✓ Branch 3 taken 15204 times.
✓ Branch 4 taken 18958 times.
✓ Branch 5 taken 26287 times.
74723 return DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight();
596 }
597
598 // called by ALLOFF()
599 13590 void HeroClass::resetflags(bool all)
600 {
601 13590 refilling=REFILL_NONE;
602 13590 inwallm=false;
603 13590 inlikelike=blowcnt=whirlwind=specialcave=hclk=fairyclk=refill_why=didstuff=0;
604 13590 usecounts.clear();
605
606
4/4
✓ Branch 0 taken 13545 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 13444 times.
13590 if(swordclk>0 || all)
607 {
608 146 swordclk=0;
609 146 verifyAWpn();
610 146 }
611
4/4
✓ Branch 0 taken 13582 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 13481 times.
13590 if(itemclk>0 || all)
612 109 itemclk=0;
613
614
2/2
✓ Branch 0 taken 13489 times.
✓ Branch 1 taken 101 times.
13590 if(all)
615 {
616 101 DivineProtectionShieldClk=0;
617
618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 if(div_prot_item != -1)
619 {
620 stop_sfx(itemsbuf[div_prot_item].usesound);
621 stop_sfx(itemsbuf[div_prot_item].usesound+1);
622 }
623
624 101 div_prot_item = -1;
625 101 hoverclk=jumping=0;
626 101 hoverflags = 0;
627 101 }
628 13590 damageovertimeclk = 0;
629 13590 newconveyorclk = 0;
630 13590 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
631
2/2
✓ Branch 0 taken 13590 times.
✓ Branch 1 taken 95130 times.
108720 for(auto q = 0; q < 7; ++q)
632 95130 hooked_undercombos[q] = -1;
633 13590 hopclk=0;
634 13590 hopdir=-1;
635 13590 attackclk=0;
636 13590 stomping=false;
637 13590 reset_swordcharge();
638 13590 diveclk=drownclk=drownCombo=0;
639 13590 action=none; FFCore.setHeroAction(none);
640 13590 conveyor_flags=0;
641 13590 magiccastclk=0;
642 13590 magicitem=-1;
643 13590 }
644
645 //Can use this for Hero->Stun. -Z
646 7856 void HeroClass::Freeze()
647 {
648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7856 times.
7856 if (action != inwind)
649 {
650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7856 times.
7856 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
651 7856 else {action=freeze; FFCore.setHeroAction(freeze);}
652 // also cancel Hero's attack
653 7856 attackclk = 0;
654 7856 }
655 7856 }
656 1463 void HeroClass::unfreeze()
657 {
658
3/4
✓ Branch 0 taken 606 times.
✓ Branch 1 taken 857 times.
✓ Branch 2 taken 606 times.
✗ Branch 3 not taken.
1463 if(action==freeze && fairyclk<1) { action=none; FFCore.setHeroAction(none); }
659
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1463 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1463 if(action==sideswimfreeze && fairyclk<1) { action=sideswimming; FFCore.setHeroAction(sideswimming); }
660 1463 }
661
662 10 void HeroClass::Drown(int32_t state)
663 {
664 // Hero should never drown if the ladder is out
665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(ladderx+laddery)
666 return;
667
668 10 drop_liftwpn();
669
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 switch(state)
670 {
671 case 1:
672 action=lavadrowning; FFCore.setHeroAction(lavadrowning);
673 attackclk=0;
674 attack=wNone;
675 attackid=-1;
676 reset_swordcharge();
677 drownclk=64;
678 z=fakez=fall=fakefall=0;
679 break;
680
681
682 default:
683 {
684
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10 if (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM)){action=sidedrowning; FFCore.setHeroAction(sidedrowning);}
685 10 else {action=drowning; FFCore.setHeroAction(drowning);}
686 10 attackclk=0;
687 10 attack=wNone;
688 10 attackid=-1;
689 10 reset_swordcharge();
690 10 drownclk=64;
691 10 z=fakez=fall=fakefall=0;
692 10 break;
693 }
694 }
695
696 10 }
697
698 1138 void HeroClass::finishedmsg()
699 {
700 //these are to cancel out any keys that Hero may
701 //be pressing so he doesn't attack at the end of
702 //a message if he was scrolling through it quickly.
703 1138 rAbtn();
704 1138 rBbtn();
705 1138 unfreeze();
706
707
3/4
✓ Branch 0 taken 1122 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1122 times.
2260 if(action == landhold1 ||
708
1/2
✓ Branch 0 taken 1122 times.
✗ Branch 1 not taken.
1122 action == landhold2 ||
709
1/2
✓ Branch 0 taken 1122 times.
✗ Branch 1 not taken.
1122 action == waterhold1 ||
710
1/2
✓ Branch 0 taken 1122 times.
✗ Branch 1 not taken.
1122 action == waterhold2 ||
711
1/2
✓ Branch 0 taken 1122 times.
✗ Branch 1 not taken.
1122 action == sidewaterhold1 ||
712 1122 action == sidewaterhold2)
713 {
714 16 holdclk = 1;
715 16 }
716 1138 }
717 35 void HeroClass::setEaten(int32_t i)
718 {
719 35 inlikelike=i;
720 35 }
721 32 int32_t HeroClass::getEaten()
722 {
723 32 return inlikelike;
724 }
725 13735928 zfix HeroClass::getX()
726 {
727 13735928 return x;
728 }
729 13152697 zfix HeroClass::getY()
730 {
731 13152697 return y;
732 }
733 41200130 zfix HeroClass::getZ()
734 {
735 41200130 return z;
736 }
737 27084087 zfix HeroClass::getFakeZ()
738 {
739 27084087 return fakez;
740 }
741 433888 zfix HeroClass::getFall()
742 {
743 433888 return fall;
744 }
745 zfix HeroClass::getFakeFall()
746 {
747 return fakefall;
748 }
749 zfix HeroClass::getXOfs()
750 {
751 return xofs;
752 }
753 zfix HeroClass::getYOfs()
754 {
755 return yofs;
756 }
757 void HeroClass::setXOfs(int32_t newxofs)
758 {
759 xofs=newxofs;
760 }
761 void HeroClass::setYOfs(int32_t newyofs)
762 {
763 yofs=newyofs;
764 }
765 int32_t HeroClass::getHXOfs()
766 {
767 return hxofs;
768 }
769 int32_t HeroClass::getHYOfs()
770 {
771 return hyofs;
772 }
773 int32_t HeroClass::getHXSz()
774 {
775 return hxsz;
776 }
777 int32_t HeroClass::getHYSz()
778 {
779 return hysz;
780 }
781 35776 zfix HeroClass::getClimbCoverX()
782 {
783 35776 return climb_cover_x;
784 }
785 35776 zfix HeroClass::getClimbCoverY()
786 {
787 35776 return climb_cover_y;
788 }
789 int32_t HeroClass::getLadderX()
790 {
791 return ladderx;
792 }
793 int32_t HeroClass::getLadderY()
794 {
795 return laddery;
796 }
797
798 437390 void HeroClass::setX(int32_t new_x)
799 {
800 437390 zfix dx=new_x-x;
801 437390 justmoved = 2;
802
1/2
✓ Branch 0 taken 437390 times.
✗ Branch 1 not taken.
437390 if(Lwpns.idFirst(wHookshot)>-1)
803 {
804 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
805 hs_startx+=(int32_t)dx;
806 }
807
808
1/2
✓ Branch 0 taken 437390 times.
✗ Branch 1 not taken.
437390 if(Lwpns.idFirst(wHSHandle)>-1)
809 {
810 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
811 }
812
813
1/2
✓ Branch 0 taken 437390 times.
✗ Branch 1 not taken.
437390 if(chainlinks.Count()>0)
814 {
815 for(int32_t j=0; j<chainlinks.Count(); j++)
816 {
817 chainlinks.spr(j)->x+=dx;
818 }
819 }
820
821 437390 x=new_x;
822
823 // A kludge
824
4/4
✓ Branch 0 taken 2543 times.
✓ Branch 1 taken 434847 times.
✓ Branch 2 taken 1591 times.
✓ Branch 3 taken 952 times.
437390 if(!diagonalMovement && dir<=down)
825 952 is_on_conveyor=true;
826 437390 }
827
828 453022 void HeroClass::setY(int32_t new_y)
829 {
830 453022 zfix dy=new_y-y;
831 453022 justmoved = 2;
832
1/2
✓ Branch 0 taken 453022 times.
✗ Branch 1 not taken.
453022 if(Lwpns.idFirst(wHookshot)>-1)
833 {
834 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
835 hs_starty+=(int32_t)dy;
836 }
837
838
1/2
✓ Branch 0 taken 453022 times.
✗ Branch 1 not taken.
453022 if(Lwpns.idFirst(wHSHandle)>-1)
839 {
840 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
841 }
842
843
1/2
✓ Branch 0 taken 453022 times.
✗ Branch 1 not taken.
453022 if(chainlinks.Count()>0)
844 {
845 for(int32_t j=0; j<chainlinks.Count(); j++)
846 {
847 chainlinks.spr(j)->y+=dy;
848 }
849 }
850
851 453022 y=new_y;
852
853 // A kludge
854
4/4
✓ Branch 0 taken 2543 times.
✓ Branch 1 taken 450479 times.
✓ Branch 2 taken 952 times.
✓ Branch 3 taken 1591 times.
453022 if(!diagonalMovement && dir>=left)
855 1591 is_on_conveyor=true;
856 453022 }
857
858 2 void HeroClass::setZ(int32_t new_z)
859 {
860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(isSideViewHero())
861 return;
862
863
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(z==0 && new_z > 0)
864 {
865
1/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 switch(action)
866 {
867 case swimming:
868 {
869 diveclk=0;
870 action=walking; FFCore.setHeroAction(walking);
871 break;
872 }
873
874 case waterhold1:
875 {
876 action=landhold1; FFCore.setHeroAction(landhold1);
877 break;
878 }
879
880 case waterhold2:
881 {
882 action=landhold2; FFCore.setHeroAction(landhold2);
883 break;
884 }
885
886 default:
887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(charging) //!DIMITODO: Let Hero jump while charging sword
888 {
889 reset_swordcharge();
890 attackclk=0;
891 }
892
893 2 break;
894 }
895 2 }
896
897
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 z=(new_z>0 ? new_z : 0);
898 2 }
899
900 void HeroClass::setFakeZ(int32_t new_z)
901 {
902 if(isSideViewHero())
903 return;
904
905 if(fakez==0 && new_z > 0)
906 {
907 switch(action)
908 {
909 case swimming:
910 {
911 diveclk=0;
912 action=walking; FFCore.setHeroAction(walking);
913 break;
914 }
915
916 case waterhold1:
917 {
918 action=landhold1; FFCore.setHeroAction(landhold1);
919 break;
920 }
921
922 case waterhold2:
923 {
924 action=landhold2; FFCore.setHeroAction(landhold2);
925 break;
926 }
927
928 default:
929 if(charging) //!DIMITODO: Let Hero jump while charging sword
930 {
931 reset_swordcharge();
932 attackclk=0;
933 }
934
935 break;
936 }
937 }
938
939 fakez=(new_z>0 ? new_z : 0);
940 }
941
942 1211 void HeroClass::setXfix(zfix new_x)
943 {
944 //Z_scripterrlog("setxdbl: %f\n",new_x);
945 1211 zfix dx=new_x-x;
946 1211 justmoved = 2;
947
1/2
✓ Branch 0 taken 1211 times.
✗ Branch 1 not taken.
1211 if(Lwpns.idFirst(wHookshot)>-1)
948 {
949 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
950 hs_startx+=(int32_t)dx;
951 }
952
953
1/2
✓ Branch 0 taken 1211 times.
✗ Branch 1 not taken.
1211 if(Lwpns.idFirst(wHSHandle)>-1)
954 {
955 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
956 }
957
958
1/2
✓ Branch 0 taken 1211 times.
✗ Branch 1 not taken.
1211 if(chainlinks.Count()>0)
959 {
960 for(int32_t j=0; j<chainlinks.Count(); j++)
961 {
962 chainlinks.spr(j)->x+=dx;
963 }
964 }
965
966 1211 x=new_x;
967
968 // A kludge
969
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1211 if(!diagonalMovement && dir<=down)
970 is_on_conveyor=true;
971 1211 }
972
973 1081 void HeroClass::setYfix(zfix new_y)
974 {
975 1081 zfix dy=new_y-y;
976 1081 justmoved = 2;
977
1/2
✓ Branch 0 taken 1081 times.
✗ Branch 1 not taken.
1081 if(Lwpns.idFirst(wHookshot)>-1)
978 {
979 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
980 hs_starty+=(int32_t)dy;
981 }
982
983
1/2
✓ Branch 0 taken 1081 times.
✗ Branch 1 not taken.
1081 if(Lwpns.idFirst(wHSHandle)>-1)
984 {
985 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
986 }
987
988
1/2
✓ Branch 0 taken 1081 times.
✗ Branch 1 not taken.
1081 if(chainlinks.Count()>0)
989 {
990 for(int32_t j=0; j<chainlinks.Count(); j++)
991 {
992 chainlinks.spr(j)->y+=dy;
993 }
994 }
995
996 1081 y=new_y;
997
998 // A kludge
999
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1081 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1081 if(!diagonalMovement && dir>=left)
1000 is_on_conveyor=true;
1001 1081 }
1002
1003 2767 void HeroClass::setZfix(zfix new_z)
1004 {
1005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2767 times.
2767 if(isSideViewHero())
1006 return;
1007
1008
4/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 2754 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 7 times.
2767 if(z==0 && new_z > 0)
1009 {
1010
1/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 switch(action)
1011 {
1012 case swimming:
1013 {
1014 diveclk=0;
1015 action=walking; FFCore.setHeroAction(walking);
1016 break;
1017 }
1018
1019 case waterhold1:
1020 {
1021 action=landhold1; FFCore.setHeroAction(landhold1);
1022 break;
1023 }
1024
1025 case waterhold2:
1026 {
1027 action=landhold2; FFCore.setHeroAction(landhold2);
1028 break;
1029 }
1030
1031 default:
1032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(charging) //!DIMITODO: Let Hero jump while charging sword
1033 {
1034 reset_swordcharge();
1035 attackclk=0;
1036 }
1037
1038 7 break;
1039 }
1040 7 }
1041
1042
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 6 times.
2767 z=(new_z>0 ? new_z : zfix(0));
1043 2767 }
1044
1045 void HeroClass::setFakeZfix(zfix new_z)
1046 {
1047 if(isSideViewHero())
1048 return;
1049
1050 if(fakez==0 && new_z > 0)
1051 {
1052 switch(action)
1053 {
1054 case swimming:
1055 {
1056 diveclk=0;
1057 action=walking; FFCore.setHeroAction(walking);
1058 break;
1059 }
1060
1061 case waterhold1:
1062 {
1063 action=landhold1; FFCore.setHeroAction(landhold1);
1064 break;
1065 }
1066
1067 case waterhold2:
1068 {
1069 action=landhold2; FFCore.setHeroAction(landhold2);
1070 break;
1071 }
1072
1073 default:
1074 if(charging) //!DIMITODO: Let Hero jump while charging sword
1075 {
1076 reset_swordcharge();
1077 attackclk=0;
1078 }
1079
1080 break;
1081 }
1082 }
1083
1084 fakez=(new_z>0 ? new_z : zfix(0));
1085 }
1086
1087 64458 void HeroClass::setFall(zfix new_fall)
1088 {
1089 64458 fall=new_fall;
1090 64458 justmoved = 2;
1091 64458 jumping=-1;
1092 64458 }
1093 void HeroClass::setFakeFall(zfix new_fall)
1094 {
1095 fakefall=new_fall;
1096 jumping=-1;
1097 }
1098 void HeroClass::setClimbCoverX(int32_t new_x)
1099 {
1100 climb_cover_x=new_x;
1101 }
1102 void HeroClass::setClimbCoverY(int32_t new_y)
1103 {
1104 climb_cover_y=new_y;
1105 }
1106 43693 int32_t HeroClass::getLStep()
1107 {
1108 43693 return lstep;
1109 }
1110 3678 int32_t HeroClass::getCharging()
1111 {
1112 3678 return charging;
1113 }
1114 59928 bool HeroClass::isCharged()
1115 {
1116 59928 return spins>0;
1117 }
1118 int32_t HeroClass::getAttackClk()
1119 {
1120 return attackclk;
1121 }
1122 void HeroClass::setAttackClk(int32_t new_clk)
1123 {
1124 attackclk=new_clk;
1125 }
1126 void HeroClass::setCharging(int32_t new_charging)
1127 {
1128 charging=new_charging;
1129 }
1130 2835005086 int32_t HeroClass::getSwordClk()
1131 {
1132 2835005086 return swordclk;
1133 }
1134 2805925184 int32_t HeroClass::getItemClk()
1135 {
1136 2805925184 return itemclk;
1137 }
1138 6 void HeroClass::setSwordClk(int32_t newclk)
1139 {
1140 6 swordclk=newclk;
1141 6 verifyAWpn();
1142 6 }
1143 108 void HeroClass::setItemClk(int32_t newclk)
1144 {
1145 108 itemclk=newclk;
1146 108 }
1147 // TODO remove, no longer needed.
1148 697113 zfix HeroClass::getModifiedX()
1149 {
1150 697113 zfix tempx=x;
1151 697113 return tempx;
1152 }
1153
1154 697113 zfix HeroClass::getModifiedY()
1155 {
1156 697113 zfix tempy=y;
1157 697113 return tempy;
1158 }
1159
1160 18253 int32_t HeroClass::getDir()
1161 {
1162 18253 return dir;
1163 }
1164 31148 void HeroClass::setDir(int32_t newdir)
1165 {
1166 31148 dir=newdir;
1167 31148 reset_hookshot();
1168 31148 }
1169 int32_t HeroClass::getHitDir()
1170 {
1171 return hitdir;
1172 }
1173 void HeroClass::setHitDir(int32_t newdir)
1174 {
1175 hitdir = newdir;
1176 }
1177 int32_t HeroClass::getClk()
1178 {
1179 return clk;
1180 }
1181 int32_t HeroClass::getPushing()
1182 {
1183 return pushing;
1184 }
1185 8597 void HeroClass::Catch()
1186 {
1187
5/6
✓ Branch 0 taken 8597 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6528 times.
✓ Branch 3 taken 2069 times.
✓ Branch 4 taken 3662 times.
✓ Branch 5 taken 2866 times.
8597 if(!inwallm && (action==none || action==walking))
1188 {
1189 5731 SetAttack();
1190 5731 attackclk=0;
1191 5731 attack=wCatching;
1192 5731 }
1193 8597 }
1194
1195 5165714 bool HeroClass::getClock()
1196 {
1197 5165714 return superman;
1198 }
1199 769 void HeroClass::setClock(bool state)
1200 {
1201 769 superman=state;
1202 769 }
1203 41951546 int32_t HeroClass::getAction() // Used by ZScript
1204 {
1205
2/2
✓ Branch 0 taken 7632 times.
✓ Branch 1 taken 41943914 times.
41951546 if(spins > 0)
1206 7632 return isspinning;
1207
2/2
✓ Branch 0 taken 17289 times.
✓ Branch 1 taken 41926625 times.
41943914 else if(charging > 0)
1208 17289 return ischarging;
1209
2/2
✓ Branch 0 taken 41889701 times.
✓ Branch 1 taken 36924 times.
41926625 else if(diveclk > 0)
1210 36924 return isdiving;
1211 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1212
1213 41889701 return action;
1214 41951546 }
1215
1216 27427007 int32_t HeroClass::getAction2() // Used by ZScript new FFCore.actions
1217 {
1218
2/2
✓ Branch 0 taken 848 times.
✓ Branch 1 taken 27426159 times.
27427007 if(spins > 0)
1219 848 return isspinning;
1220
2/2
✓ Branch 0 taken 1921 times.
✓ Branch 1 taken 27424238 times.
27426159 else if(charging > 0)
1221 1921 return ischarging;
1222
2/2
✓ Branch 0 taken 27330350 times.
✓ Branch 1 taken 93888 times.
27424238 else if(diveclk > 0)
1223 93888 return isdiving;
1224 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1225
1226 27330350 return -1;
1227 27427007 }
1228
1229 392 void HeroClass::setAction(actiontype new_action) // Used by ZScript
1230 {
1231
4/8
✓ Branch 0 taken 392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 392 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 392 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 392 times.
784 if(new_action==dying || new_action==won || new_action==scrolling ||
1232
3/6
✓ Branch 0 taken 392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 392 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 392 times.
✗ Branch 5 not taken.
392 new_action==inwind || new_action==ischarging || new_action==sideswimischarging ||
1233 392 new_action==hopping) //!DIMITODO: allow setting sideswimming stuff
1234 return; // Can't use these actions.
1235
1236
3/6
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 193 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
392 if (!isSideViewHero() && (new_action>=sideswimming && new_action <= sideswimischarging))
1237 return;
1238
1239
1/2
✓ Branch 0 taken 392 times.
✗ Branch 1 not taken.
392 if(new_action==rafting)
1240 {
1241 if(get_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING)) return;
1242 if(!(isRaftFlag(nextflag(x+8,y+8,dir,false))||isRaftFlag(nextflag(x+8,y+8,dir,true))))
1243 return;
1244 }
1245
1246
1247
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 392 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
392 if(magicitem>-1 && itemsbuf[magicitem].family==itype_divineescape)
1248 {
1249 // Using Divine Escape
1250 if(magiccastclk<96)
1251 {
1252 // Not cast yet; cancel it
1253 magicitem=-1;
1254 magiccastclk=0;
1255 }
1256 else
1257 // Already activated; don't do anything
1258 return;
1259 }
1260
1261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 392 times.
392 if(action==inwind) // Remove from whirlwind
1262 {
1263 xofs=0;
1264 whirlwind=0;
1265 lstep=0;
1266 if ( dontdraw < 2 ) { dontdraw=0; }
1267 }
1268
2/4
✓ Branch 0 taken 392 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 392 times.
392 else if(action==freeze||action==sideswimfreeze) // Might be in enemy wind
1269 {
1270 sprite* wind=0;
1271 bool foundWind=false;
1272 for(int32_t i=0; i<Ewpns.Count(); i++)
1273 {
1274 wind=Ewpns.spr(i);
1275 if(wind->id==ewWind && wind->misc==999)
1276 {
1277 foundWind=true;
1278 break;
1279 }
1280 }
1281
1282 if(foundWind)
1283 {
1284 xofs=0;
1285 if ( dontdraw < 2 ) { dontdraw=false; }
1286 wind->misc=-1;
1287 x=wind->x;
1288 y=wind->y;
1289 }
1290 }
1291
1292 //Unless compat rule is on, reset hopping clocks when writing action!
1293
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 392 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
392 if(action == hopping && !get_bit(quest_rules,qr_NO_OVERWRITING_HOPPING))
1294 {
1295 hopclk = 0;
1296 hopdir = -1;
1297 }
1298
1299
3/4
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 267 times.
392 if(new_action != attacking && new_action != sideswimattacking)
1300 {
1301 267 attackclk=0;
1302
1303
1/2
✓ Branch 0 taken 267 times.
✗ Branch 1 not taken.
267 if(attack==wHookshot)
1304 reset_hookshot();
1305 267 }
1306
2/4
✓ Branch 0 taken 392 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 392 times.
392 if(new_action != isspinning && new_action != sideswimisspinning)
1307 {
1308 392 charging = 0;
1309 392 spins = 0;
1310 392 }
1311
1312
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 392 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
392 if(action == falling && new_action != falling)
1313 {
1314 fallclk = 0; //Stop falling;
1315 }
1316
1317
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 392 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
392 if (action == rafting && new_action != rafting)
1318 {
1319 raftwarpx = x;//If you wanted to make Link stop rafting on a dock combo, don't make the dock retrigger the raft.
1320 raftwarpy = y;
1321 }
1322
1323
2/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 125 times.
✓ Branch 5 taken 267 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
392 switch(new_action)
1324 {
1325 case isspinning:
1326 case sideswimisspinning:
1327 if(attack==wSword)
1328 {
1329 attackclk = SWORDCHARGEFRAME+1;
1330 charging = 0;
1331
1332 if(spins==0)
1333 spins = 5;
1334 }
1335 return;
1336
1337 case isdiving:
1338 if(action==swimming && diveclk==0)
1339 {
1340 int32_t flippers_id = current_item_id(itype_flippers);
1341 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2)); // Who cares about qr_NODIVING? It's the questmaker's business.
1342 }
1343 return;
1344
1345 case drowning:
1346 case sidedrowning:
1347 //I would add a sanity check to see if Hero is in water, but I *KNOW* that quests have used this
1348 // INTENTIONALLY while Hero is on Land, as a blink-out effect. :( -Z
1349 if(!drownclk)
1350 Drown();
1351
1352 break;
1353
1354 case lavadrowning:
1355 //Lavadrowning is just drowning but with a different argument. Simplicity! -Dimi
1356 if(!drownclk)
1357 Drown(1);
1358
1359 break;
1360
1361 case falling:
1362 if(!fallclk)
1363 {
1364 //If there is a pit under Hero, use it's combo.
1365 if(int32_t c = getpitfall(x+8,y+(bigHitbox?8:12))) fallCombo = c;
1366 else if(int32_t c = getpitfall(x,y+(bigHitbox?0:8))) fallCombo = c;
1367 else if(int32_t c = getpitfall(x+15,y+(bigHitbox?0:8))) fallCombo = c;
1368 else if(int32_t c = getpitfall(x,y+15)) fallCombo = c;
1369 else if(int32_t c = getpitfall(x+15,y+15)) fallCombo = c;
1370 //Else, use a null value; triggers default pit values
1371 else fallCombo = 0;
1372 fallclk = PITFALL_FALL_FRAMES;
1373 }
1374 break;
1375
1376 case gothit:
1377 case swimhit:
1378 case sideswimhit:
1379 if(!hclk)
1380 hclk=48;
1381
1382 break;
1383
1384 case landhold1:
1385 case landhold2:
1386 case waterhold1:
1387 case waterhold2:
1388 case sidewaterhold1:
1389 case sidewaterhold2:
1390 if(!holdclk)
1391 holdclk=130;
1392
1393 attack=none;
1394 break;
1395
1396 case attacking:
1397 case sideswimattacking:
1398 125 attack=none;
1399 125 break;
1400
1401 default:
1402 267 break;
1403 }
1404
1405 392 action=new_action; FFCore.setHeroAction(new_action);
1406 392 }
1407
1408 void HeroClass::setHeldItem(int32_t newitem)
1409 {
1410 holditem=newitem;
1411 }
1412 17 int32_t HeroClass::getHeldItem()
1413 {
1414 17 return holditem;
1415 }
1416 6175519 bool HeroClass::isDiving()
1417 {
1418 6175519 int32_t flippers_id = current_item_id(itype_flippers);
1419
2/2
✓ Branch 0 taken 4513516 times.
✓ Branch 1 taken 1662003 times.
6175519 return (diveclk > (flippers_id < 0 ? 30 : itemsbuf[flippers_id].misc2));
1420 }
1421 13639859 bool HeroClass::isSwimming()
1422 {
1423
4/6
✓ Branch 0 taken 13498187 times.
✓ Branch 1 taken 141672 times.
✓ Branch 2 taken 13498187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13498187 times.
✗ Branch 5 not taken.
27138046 return ((action==swimming)||(action==sideswimming)||IsSideSwim()||
1424
4/4
✓ Branch 0 taken 13496757 times.
✓ Branch 1 taken 1430 times.
✓ Branch 2 taken 390 times.
✓ Branch 3 taken 13496367 times.
13498187 (action==waterhold1)||(action==waterhold2)||
1425 13496367 (hopclk==0xFF));
1426 }
1427
1428 769 void HeroClass::setDontDraw(byte new_dontdraw)
1429 {
1430 769 dontdraw=new_dontdraw;
1431 769 }
1432
1433 569511 byte HeroClass::getDontDraw()
1434 {
1435 569511 return dontdraw;
1436 }
1437
1438 void HeroClass::setHClk(int32_t newhclk)
1439 {
1440 hclk=newhclk;
1441 }
1442
1443 87306 int32_t HeroClass::getHClk()
1444 {
1445 87306 return hclk;
1446 }
1447
1448 4168290 int32_t HeroClass::getSpecialCave()
1449 {
1450 4168290 return specialcave; // used only by maps.cpp
1451 }
1452
1453 333 void HeroClass::init()
1454 {
1455 333 usecounts.clear();
1456 333 scale = 0;
1457 333 rotation = 0;
1458 333 do_animation = 1;
1459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 333 times.
333 if(lift_wpn)
1460 {
1461 delete lift_wpn;
1462 lift_wpn = nullptr;
1463 }
1464 333 liftclk = 0;
1465 333 tliftclk = 0;
1466 333 liftheight = 0;
1467 333 liftflags = 0;
1468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 333 times.
333 if ( dontdraw != 2 ) { dontdraw = 0; } //scripted dontdraw == 2, normal == 1, draw hero == 0
1469 333 hookshot_used=false;
1470 333 justmoved = 0;
1471 333 hookshot_frozen=false;
1472 333 onpassivedmg=false;
1473 333 dir = up;
1474 333 damageovertimeclk = 0;
1475 333 newconveyorclk = 0;
1476 333 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
1477
2/2
✓ Branch 0 taken 2331 times.
✓ Branch 1 taken 333 times.
2664 for(auto q = 0; q < 7; ++q)
1478 2331 hooked_undercombos[q] = -1;
1479 333 shiftdir = -1;
1480 333 sideswimdir = right;
1481 333 holddir = -1;
1482 333 landswim = 0;
1483 333 sdir = up;
1484 333 ilswim=true;
1485 333 walkable=false;
1486 333 moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL | FLAG_CAN_WATERDROWN;
1487 333 warp_sound = 0;
1488 333 subscr_speed = zinit.subscrSpeed;
1489 333 steprate = zinit.heroStep;
1490 333 is_warping = false;
1491 333 coyotetime = 0;
1492
1493 333 hammer_swim_up_offset = hammeroffsets[0];
1494 333 hammer_swim_down_offset = hammeroffsets[1];
1495 333 hammer_swim_left_offset = hammeroffsets[2];
1496 333 hammer_swim_right_offset = hammeroffsets[3];
1497
1498 333 prompt_combo = prompt_x = prompt_y = prompt_cset = 0;
1499
1500
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 236 times.
333 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
1501 {
1502 97 x=tmpscr->warpreturnx[0];
1503 97 y=tmpscr->warpreturny[0];
1504 97 }
1505 else
1506 {
1507 236 x=tmpscr->warparrivalx;
1508 236 y=tmpscr->warparrivaly;
1509 }
1510
1511 333 z=fakez=fall=fakefall=0;
1512 333 hzsz = 12; // So that flying peahats can still hit him.
1513
1514
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 268 times.
333 if(x==0) dir=right;
1515
1516
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 332 times.
333 if(x==240) dir=left;
1517
1518
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 261 times.
333 if(y==0) dir=down;
1519
1520
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 239 times.
333 if(y==160) dir=up;
1521
1522 333 lstep=0;
1523 333 skipstep=0;
1524 333 autostep=false;
1525 333 attackclk=holdclk=hoverclk=jumping=raftclk=0;
1526 333 attack=wNone;
1527 333 attackid=-1;
1528 333 action=none; FFCore.setHeroAction(none); tempaction=none;
1529 333 xofs=0;
1530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 333 times.
333 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
1531 333 cs=6;
1532 333 pushing=fairyclk=0;
1533 333 id=0;
1534 333 inlikelike=0;
1535 333 superman=inwallm=false;
1536 333 scriptcoldet=1;
1537 333 blowcnt=whirlwind=specialcave=0;
1538 333 hopclk=diveclk=fallclk=0;
1539 333 fallCombo = 0;
1540 333 pit_pulldir = -1;
1541 333 hopdir=-1;
1542 333 conveyor_flags=0;
1543 333 drunkclk=0;
1544 333 lstunclock = 0;
1545 333 is_conveyor_stunned=0;
1546 333 convey_forcex=convey_forcey=0;
1547 333 drawstyle=3;
1548 333 ffwarp = false;
1549 333 stepoutindex=stepoutwr=stepoutdmap=stepoutscr=0;
1550 333 stepnext=stepsecret=-1;
1551 333 ffpit = false;
1552 333 respawn_x=x;
1553 333 respawn_y=y;
1554 333 respawn_dmap=currdmap;
1555 333 respawn_scr=currscr;
1556 333 falling_oldy = y;
1557 333 magiccastclk=0;
1558 333 magicitem = div_prot_item = -1;
1559 333 last_lens_id = 0; //Should be -1 (-Z)
1560 333 last_savepoint_id = 0;
1561 333 misc_internal_hero_flags = 0;
1562 333 last_cane_of_byrna_item_id = -1;
1563 333 on_sideview_ladder = false;
1564 333 switchblock_z = 0;
1565 333 switchblock_offset = false;
1566 333 extra_jump_count = 0;
1567 333 hoverflags = 0;
1568 333 lbunnyclock = 0;
1569
1570
2/2
✓ Branch 0 taken 10656 times.
✓ Branch 1 taken 333 times.
10989 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
1571
1572 333 setBigHitbox(get_bit(quest_rules, qr_LTTPCOLLISION));
1573 333 diagonalMovement=(get_bit(quest_rules,qr_LTTPWALK));
1574
1575 333 shield_active = false;
1576 333 shield_forcedir = -1;
1577 333 active_shield_id = -1;
1578
1579 //2.6
1580 333 preventsubscreenfalling = false; //-Z
1581 333 walkspeed = 0; //not used, yet. -Z
1582
2/2
✓ Branch 0 taken 5661 times.
✓ Branch 1 taken 333 times.
5994 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][0] = 0;
1583
2/2
✓ Branch 0 taken 5661 times.
✓ Branch 1 taken 333 times.
5994 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][1] = 0;
1584
2/2
✓ Branch 0 taken 48618 times.
✓ Branch 1 taken 333 times.
48951 for ( int32_t q = 0; q < wMax; q++ )
1585 {
1586 48618 defence[q] = hero_defence[q]; //we will need to have a Hero section in the quest load/save code! -Z Added 3/26/21 - Jman
1587 //zprint2("defence[%d] is: %d\n", q, defence[q]);
1588 48618 }
1589 //Run script!
1590
4/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 302 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 16 times.
333 if (( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 ) && (game->get_hasplayed()) ) //if (!hasplayed) runs in game_loop()
1591 {
1592 15 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_INIT, SCRIPT_PLAYER_INIT);
1593 15 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_INIT);
1594 15 FFCore.initZScriptHeroScripts(); //Clear the stack and the refinfo data to be ready for Hero's active script.
1595 15 set_respawn_point(); //screen entry at spawn; //This should be after the init script, so that Hero->X and Hero->Y set by the script
1596 //are properly set by the engine.
1597 15 }
1598 333 FFCore.nostepforward = 0;
1599
1600
4/4
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 236 times.
333 if (!replay_is_active() || replay_get_version() >= 12)
1601 97 z3step = 2;
1602 333 }
1603
1604 7284510 void HeroClass::draw_under(BITMAP* dest)
1605 {
1606 7284510 int32_t c_raft=current_item_id(itype_raft);
1607 7284510 int32_t c_ladder=current_item_id(itype_ladder);
1608
1609
3/4
✓ Branch 0 taken 80476 times.
✓ Branch 1 taken 7204034 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80476 times.
7284510 if(action==rafting && c_raft >-1)
1610 {
1611
4/4
✓ Branch 0 taken 59051 times.
✓ Branch 1 taken 21425 times.
✓ Branch 2 taken 41054 times.
✓ Branch 3 taken 39422 times.
80476 if(((dir==left) || (dir==right)) && (get_bit(quest_rules,qr_RLFIX)))
1612 {
1613 78844 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1614 39422 itemsbuf[c_raft].csets&15, rotate_value((itemsbuf[c_raft].misc_flags>>2)&3)^3);
1615 39422 }
1616 else
1617 {
1618 82108 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1619 41054 itemsbuf[c_raft].csets&15, (itemsbuf[c_raft].misc_flags>>2)&3);
1620 }
1621 80476 }
1622
1623
3/4
✓ Branch 0 taken 97855 times.
✓ Branch 1 taken 7186655 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97855 times.
7284510 if(ladderx+laddery && c_ladder >-1)
1624 {
1625
4/4
✓ Branch 0 taken 44432 times.
✓ Branch 1 taken 53423 times.
✓ Branch 2 taken 26065 times.
✓ Branch 3 taken 18367 times.
97855 if((ladderdir>=left) && (get_bit(quest_rules,qr_RLFIX)))
1626 {
1627 52130 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1628 26065 itemsbuf[c_ladder].csets&15, rotate_value((itemsbuf[iRaft].misc_flags>>2)&3)^3);
1629 26065 }
1630 else
1631 {
1632 143580 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1633 71790 itemsbuf[c_ladder].csets&15, (itemsbuf[c_ladder].misc_flags>>2)&3);
1634 }
1635 97855 }
1636 7284510 }
1637
1638 3721 void HeroClass::drawshadow(BITMAP* dest, bool translucent)
1639 {
1640 3721 int32_t tempy=yofs;
1641 3721 yofs+=8;
1642 3721 shadowtile = wpnsbuf[spr_shadow].tile;
1643 3721 sprite::drawshadow(dest,translucent);
1644 3721 yofs=tempy;
1645 3721 }
1646
1647 // The Stone of Agony reacts to these flags.
1648 487612 bool HeroClass::agonyflag(int32_t flag)
1649 {
1650
2/2
✓ Branch 0 taken 487580 times.
✓ Branch 1 taken 32 times.
487612 switch(flag)
1651 {
1652 case mfWHISTLE:
1653 case mfANYFIRE:
1654 case mfARROW:
1655 case mfBOMB:
1656 case mfSBOMB:
1657 case mfBRANG:
1658 case mfMBRANG:
1659 case mfFBRANG:
1660 case mfSARROW:
1661 case mfGARROW:
1662 case mfSTRONGFIRE:
1663 case mfMAGICFIRE:
1664 case mfDIVINEFIRE:
1665 case mfWANDMAGIC:
1666 case mfREFMAGIC:
1667 case mfREFFIREBALL:
1668 case mfSWORD:
1669 case mfWSWORD:
1670 case mfMSWORD:
1671 case mfXSWORD:
1672 case mfSWORDBEAM:
1673 case mfWSWORDBEAM:
1674 case mfMSWORDBEAM:
1675 case mfXSWORDBEAM:
1676 case mfHOOKSHOT:
1677 case mfWAND:
1678 case mfHAMMER:
1679 case mfSTRIKE:
1680 32 return true;
1681 }
1682
1683 487580 return false;
1684 487612 }
1685
1686
1687 // Find the attack power of the current melee weapon.
1688 // The Whimsical Ring is applied on a target-by-target basis.
1689 469074 int32_t HeroClass::weaponattackpower(int32_t itid)
1690 {
1691
1/2
✓ Branch 0 taken 469074 times.
✗ Branch 1 not taken.
469074 if(itid < 0)
1692 {
1693 itid = current_item_id(attack==wCByrna ? itype_cbyrna
1694 : attack==wWand ? itype_wand
1695 : attack==wHammer ? itype_hammer
1696 : itype_sword);
1697 }
1698
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 469054 times.
469074 int32_t power = attack==wCByrna ? itemsbuf[itid].misc4 : itemsbuf[itid].power;
1699
1700 // Multiply it by the power of the spin attack/quake hammer, if applicable.
1701
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 468500 times.
469074 if(spins > 0)
1702 {
1703 574 int scr = currentscroll;
1704
1/2
✓ Branch 0 taken 574 times.
✗ Branch 1 not taken.
574 if(scr < 0)
1705 {
1706 scr = current_item_id(attack==wHammer ? (spins>1?itype_quakescroll2:itype_quakescroll)
1707 : (spins>5 || current_item_id(itype_spinscroll) < 0)
1708 ? itype_spinscroll2 : itype_spinscroll);
1709 }
1710 574 power *= itemsbuf[scr].power;
1711 574 }
1712 468500 else currentscroll = -1;
1713 469074 return power;
1714 }
1715
1716 #define NET_CLK_TOTAL 24
1717 #define NET_DIR_INC (NET_CLK_TOTAL/3)
1718 // Must only be called once per frame!
1719 void HeroClass::positionNet(weapon *w, int32_t itemid)
1720 {
1721 itemid = vbound(itemid, 0, MAXITEMS-1);
1722 int32_t t = w->o_tile,
1723 wx = 1, wy = 1;
1724
1725 //Invert positioning clock if right-handed animation
1726 int32_t clock = (itemsbuf[itemid].flags&ITEM_FLAG2 ? (NET_CLK_TOTAL-1)-attackclk : attackclk);
1727 if(clock >= NET_CLK_TOTAL)
1728 w->dead = 0;
1729 int32_t tiledir = dir;
1730 switch(dir)
1731 {
1732 case up:
1733 {
1734 if(clock < NET_DIR_INC) tiledir = l_up;
1735 else if(clock >= NET_DIR_INC*2) tiledir = r_up;
1736 break;
1737 }
1738 case down:
1739 {
1740 if(clock < NET_DIR_INC) tiledir = r_down;
1741 else if(clock >= NET_DIR_INC*2) tiledir = l_down;
1742 break;
1743 }
1744 case left:
1745 {
1746 if(clock < NET_DIR_INC) tiledir = l_down;
1747 else if(clock >= NET_DIR_INC*2) tiledir = l_up;
1748 break;
1749 }
1750 case right:
1751 {
1752 if(clock < NET_DIR_INC) tiledir = r_up;
1753 else if(clock >= NET_DIR_INC*2) tiledir = r_down;
1754 break;
1755 }
1756 }
1757 int32_t offs = 0;
1758 if(tiledir > right)
1759 offs = ((clock%NET_DIR_INC)<NET_DIR_INC/2) ? 1 : 0;
1760 else offs = vbound(((clock%NET_DIR_INC)/(NET_DIR_INC/3))-1,-1,1);
1761 //One of 8 positions
1762 switch(tiledir)
1763 {
1764 case up:
1765 {
1766 wx = 6*offs;
1767 wy = -14;
1768 break;
1769 }
1770 case r_up:
1771 {
1772 wx = (offs ? 10 : 14);
1773 wy = (offs ? -12 : -10);
1774 break;
1775 }
1776 case right:
1777 {
1778 wx = 14;
1779 wy = 6*offs;
1780 break;
1781 }
1782 case r_down:
1783 {
1784 wx = (offs ? 14 : 10);
1785 wy = (offs ? 10 : 12);
1786 break;
1787 }
1788 case down:
1789 {
1790 wx = -6*offs;
1791 wy = 14;
1792 break;
1793 }
1794 case l_down:
1795 {
1796 wx = (offs ? -10 : -14);
1797 wy = (offs ? 12 : 10);
1798 break;
1799 }
1800 case left:
1801 {
1802 wx = -14;
1803 wy = -6*offs;
1804 break;
1805 }
1806 case l_up:
1807 {
1808 wx = (offs ? -14 : -10);
1809 wy = (offs ? -10 : -12);
1810 break;
1811 }
1812 }
1813
1814 w->x = x+wx;
1815 w->y = y+wy-(54-(yofs))-fakez;
1816 w->z = (z+zofs);
1817 w->fakez = fakez;
1818 w->tile = t+tiledir;
1819 w->power = 0;
1820 w->dir = dir;
1821 w->doAutoRotate(true);
1822 }
1823 412628 void HeroClass::positionSword(weapon *w, int32_t itemid)
1824 {
1825 //if ( w->ScriptGenerated ) return; //t/b/a for script-generated swords.
1826 //if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
1827 412628 itemid=vbound(itemid, 0, MAXITEMS-1);
1828 // Place a sword weapon at the right spot.
1829 412628 int32_t wy=1;
1830 412628 int32_t wx=1;
1831 412628 int32_t f=0,t,cs2;
1832
1833 412628 t = w->o_tile;
1834 412628 cs2 = w->o_cset;
1835 412628 slashxofs=0;
1836 412628 slashyofs=0;
1837
1838
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 94214 times.
✓ Branch 2 taken 89955 times.
✓ Branch 3 taken 113144 times.
✓ Branch 4 taken 115315 times.
412628 switch(dir)
1839 {
1840 case up:
1841 94214 wx=-1;
1842 94214 wy=-12;
1843
1844
7/8
✓ Branch 0 taken 6693 times.
✓ Branch 1 taken 87521 times.
✓ Branch 2 taken 5640 times.
✓ Branch 3 taken 1053 times.
✓ Branch 4 taken 5230 times.
✓ Branch 5 taken 410 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5230 times.
94214 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1845 {
1846
2/2
✓ Branch 0 taken 3418 times.
✓ Branch 1 taken 1812 times.
5230 if(attackclk>10) //extended stab
1847 {
1848 1812 slashyofs-=3;
1849 1812 wy-=2;
1850 1812 }
1851
1852
2/2
✓ Branch 0 taken 4778 times.
✓ Branch 1 taken 452 times.
5230 if(attackclk>=14) //retracting stab
1853 {
1854 452 slashyofs+=3;
1855 452 wy+=2;
1856 452 }
1857 5230 }
1858 else
1859 {
1860
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 88698 times.
88984 if(attackclk==SWORDCHARGEFRAME)
1861 {
1862 286 wy+=4;
1863 286 }
1864
2/2
✓ Branch 0 taken 8612 times.
✓ Branch 1 taken 80086 times.
88698 else if(attackclk==13)
1865 {
1866 8612 wy+=4;
1867 8612 }
1868
2/2
✓ Branch 0 taken 71572 times.
✓ Branch 1 taken 8514 times.
80086 else if(attackclk==14)
1869 {
1870 8514 wy+=8;
1871 8514 }
1872 }
1873
1874 94214 break;
1875
1876 case down:
1877 89955 f=get_bit(quest_rules,qr_SWORDWANDFLIPFIX)?3:2;
1878 89955 wy=11;
1879
1880
7/8
✓ Branch 0 taken 9260 times.
✓ Branch 1 taken 80695 times.
✓ Branch 2 taken 8503 times.
✓ Branch 3 taken 757 times.
✓ Branch 4 taken 8143 times.
✓ Branch 5 taken 360 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 8143 times.
89955 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1881 {
1882
2/2
✓ Branch 0 taken 5288 times.
✓ Branch 1 taken 2855 times.
8143 if(attackclk>10) //extended stab
1883 {
1884 2855 slashyofs+=3;
1885 2855 wy+=2;
1886 2855 }
1887
1888
2/2
✓ Branch 0 taken 7441 times.
✓ Branch 1 taken 702 times.
8143 if(attackclk>=14) //retracting stab
1889 {
1890 702 slashyofs-=3;
1891 702 wy-=2;
1892 702 }
1893 8143 }
1894 else
1895 {
1896
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 81212 times.
81812 if(attackclk==SWORDCHARGEFRAME)
1897 {
1898 600 wy-=2;
1899 600 }
1900
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 73220 times.
81212 else if(attackclk==13)
1901 {
1902 7992 wy-=4;
1903 7992 }
1904
2/2
✓ Branch 0 taken 65256 times.
✓ Branch 1 taken 7964 times.
73220 else if(attackclk==14)
1905 {
1906 7964 wy-=8;
1907 7964 }
1908 }
1909
1910 89955 break;
1911
1912 case left:
1913 113144 f=1;
1914 113144 wx=-11;
1915 113144 ++t;
1916
1917
7/8
✓ Branch 0 taken 12751 times.
✓ Branch 1 taken 100393 times.
✓ Branch 2 taken 10433 times.
✓ Branch 3 taken 2318 times.
✓ Branch 4 taken 9581 times.
✓ Branch 5 taken 852 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9581 times.
113144 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1918 {
1919
2/2
✓ Branch 0 taken 6140 times.
✓ Branch 1 taken 3441 times.
9581 if(attackclk>10) //extended stab
1920 {
1921 3441 slashxofs-=4;
1922 3441 wx-=7;
1923 3441 }
1924
1925
2/2
✓ Branch 0 taken 8726 times.
✓ Branch 1 taken 855 times.
9581 if(attackclk>=14) //retracting stab
1926 {
1927 855 slashxofs+=3;
1928 855 wx+=7;
1929 855 }
1930 9581 }
1931 else
1932 {
1933
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 103360 times.
103563 if(attackclk==SWORDCHARGEFRAME)
1934 {
1935 203 wx+=2;
1936 203 }
1937
2/2
✓ Branch 0 taken 10192 times.
✓ Branch 1 taken 93168 times.
103360 else if(attackclk==13)
1938 {
1939 10192 wx+=4;
1940 10192 }
1941
2/2
✓ Branch 0 taken 83012 times.
✓ Branch 1 taken 10156 times.
93168 else if(attackclk==14)
1942 {
1943 10156 wx+=8;
1944 10156 }
1945 }
1946
1947 113144 break;
1948
1949 case right:
1950 115315 wx=11;
1951 115315 ++t;
1952
1953
7/8
✓ Branch 0 taken 12948 times.
✓ Branch 1 taken 102367 times.
✓ Branch 2 taken 11071 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 9237 times.
✓ Branch 5 taken 1834 times.
✓ Branch 6 taken 9237 times.
✗ Branch 7 not taken.
115315 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1954 {
1955
2/2
✓ Branch 0 taken 5924 times.
✓ Branch 1 taken 3313 times.
9237 if(attackclk>10) //extended stab
1956 {
1957 3313 slashxofs+=4;
1958 3313 wx+=7;
1959 3313 }
1960
1961
2/2
✓ Branch 0 taken 8410 times.
✓ Branch 1 taken 827 times.
9237 if(attackclk>=14) //retracting stab
1962 {
1963 827 slashxofs-=3;
1964 827 wx-=7;
1965 827 }
1966 9237 }
1967 else
1968 {
1969
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 105483 times.
106078 if(attackclk==SWORDCHARGEFRAME)
1970 {
1971 595 wx-=2;
1972 595 }
1973
2/2
✓ Branch 0 taken 10375 times.
✓ Branch 1 taken 95108 times.
105483 else if(attackclk==13)
1974 {
1975 10375 wx-=4;
1976 10375 }
1977
2/2
✓ Branch 0 taken 84760 times.
✓ Branch 1 taken 10348 times.
95108 else if(attackclk==14)
1978 {
1979 10348 wx-=8;
1980 10348 }
1981 }
1982
1983 115315 break;
1984 }
1985
1986
6/6
✓ Branch 0 taken 41652 times.
✓ Branch 1 taken 370976 times.
✓ Branch 2 taken 32211 times.
✓ Branch 3 taken 9441 times.
✓ Branch 4 taken 11429 times.
✓ Branch 5 taken 20782 times.
412628 if(game->get_canslash() && itemsbuf[itemid].flags & ITEM_FLAG4 && attackclk<11)
1987 {
1988 20782 int32_t wpn2=itemsbuf[itemid].wpn2;
1989 20782 wpn2=vbound(wpn2, 0, MAXWPNS);
1990
1991 //slashing tiles
1992
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3418 times.
✓ Branch 2 taken 5294 times.
✓ Branch 3 taken 6140 times.
✓ Branch 4 taken 5930 times.
20782 switch(dir)
1993 {
1994 case up:
1995 3418 wx=15;
1996 3418 wy=-3;
1997 3418 ++t;
1998 3418 f=0; //starts pointing right
1999
2000
2/2
✓ Branch 0 taken 1533 times.
✓ Branch 1 taken 1885 times.
3418 if(attackclk>=7)
2001 {
2002 1885 wy-=9;
2003 1885 wx-=3;
2004 1885 t = wpnsbuf[wpn2].tile;
2005 1885 cs2 = wpnsbuf[wpn2].csets&15;
2006 1885 f=0;
2007 1885 }
2008
2009 3418 break;
2010
2011 case down:
2012 5294 wx=-13;
2013 5294 wy=-1;
2014 5294 ++t;
2015 5294 f=1; //starts pointing left
2016
2017
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 2990 times.
5294 if(attackclk>=7)
2018 {
2019 2990 wy+=15;
2020 2990 wx+=2;
2021 2990 t = wpnsbuf[wpn2].tile;
2022 2990 cs2 = wpnsbuf[wpn2].csets&15;
2023 2990 ++t;
2024 2990 f=0;
2025 2990 }
2026
2027 5294 break;
2028
2029 case left:
2030 6140 wx=3;
2031 6140 wy=-15;
2032 6140 --t;
2033 6140 f=0; //starts pointing up
2034
2035
2/2
✓ Branch 0 taken 2658 times.
✓ Branch 1 taken 3482 times.
6140 if(attackclk>=7)
2036 {
2037 3482 wx-=15;
2038 3482 wy+=3;
2039 3482 slashxofs-=1;
2040 3482 t = wpnsbuf[wpn2].tile;
2041 3482 cs2 = wpnsbuf[wpn2].csets&15;
2042 3482 t+=2;
2043 3482 f=0;
2044 3482 }
2045
2046 6140 break;
2047
2048 case right:
2049 5930 --t;
2050
2051
2/4
✓ Branch 0 taken 5930 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5930 times.
5930 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2052 {
2053 wx=1;
2054 wy=13;
2055 f=2;
2056 }
2057 else
2058 {
2059 5930 wx=3;
2060 5930 wy=-15;
2061 5930 f=0;
2062 }
2063
2064
2/2
✓ Branch 0 taken 2579 times.
✓ Branch 1 taken 3351 times.
5930 if(attackclk>=7)
2065 {
2066 3351 wx+=15;
2067 3351 slashxofs+=1;
2068 3351 t = wpnsbuf[wpn2].tile;
2069 3351 cs2 = wpnsbuf[wpn2].csets&15;
2070
2071
2/4
✓ Branch 0 taken 3351 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3351 times.
3351 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2072 {
2073 wx-=1;
2074 wy-=2;
2075 }
2076 else
2077 {
2078 3351 t+=3;
2079 3351 f=0;
2080 3351 wy+=3;
2081 }
2082 3351 }
2083
2084 5930 break;
2085 }
2086 20782 }
2087
2088 412628 int32_t itemid2 = current_item_id(itype_chargering);
2089
2090
4/4
✓ Branch 0 taken 21741 times.
✓ Branch 1 taken 390887 times.
✓ Branch 2 taken 412096 times.
✓ Branch 3 taken 532 times.
412628 if(charging>(itemid2>=0 ? itemsbuf[itemid2].misc1 : 64))
2091 {
2092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 cs2=(BSZ ? (frame&3)+6 : ((frame>>2)&1)+7);
2093 532 }
2094
2095 /*if(BSZ || ((isdungeon() && currscr<128) && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)))
2096 {
2097 wy+=2;
2098 }*/
2099 412628 w->x = x+wx;
2100 412628 w->y = y+wy-(54-(yofs+slashyofs))-fakez;
2101 412628 w->z = (z+zofs);
2102 412628 w->tile = t;
2103 412628 w->flip = f;
2104 412628 w->power = weaponattackpower(itemid);
2105 412628 w->dir = dir;
2106 412628 w->doAutoRotate(true);
2107 412628 }
2108
2109 int HeroClass::getHammerState() const
2110 {
2111 if(attack == wHammer)
2112 {
2113 if(attackclk >= 15)
2114 return 3;
2115 if(attackclk >= 13)
2116 return 2;
2117 return 1;
2118 }
2119 return 0;
2120 }
2121
2122 7324842 void HeroClass::draw(BITMAP* dest)
2123 {
2124 /*{
2125 char buf[36];
2126 //sprintf(buf,"%d %d %d %d %d %d %d",dir, action, attack, attackclk, charging, spins, tapping);
2127 textout_shadowed_ex(framebuf,font, buf, 2,72,WHITE,BLACK,-1);
2128 }*/
2129 7324842 int32_t oxofs = xofs, oyofs = yofs;
2130 7324842 bool shieldModify = false;
2131
2/2
✓ Branch 0 taken 7307734 times.
✓ Branch 1 taken 17108 times.
7324842 bool invisible=(dontdraw>0) || (tmpscr->flags3&fINVISHERO);
2132
2133 {
2134
2/2
✓ Branch 0 taken 3241 times.
✓ Branch 1 taken 7321601 times.
7324842 if(action==dying)
2135 {
2136
2/2
✓ Branch 0 taken 2526 times.
✓ Branch 1 taken 715 times.
3241 if(!invisible)
2137 {
2138
1/2
✓ Branch 0 taken 715 times.
✗ Branch 1 not taken.
715 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2139 715 sprite::draw(dest);
2140 715 }
2141 3241 goto herodraw_end;
2142 }
2143
2144 7321601 bool useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2145
2146
2147
2/2
✓ Branch 0 taken 73318 times.
✓ Branch 1 taken 7248283 times.
7321601 if(!invisible)
2148
6/6
✓ Branch 0 taken 6291211 times.
✓ Branch 1 taken 957072 times.
✓ Branch 2 taken 3992514 times.
✓ Branch 3 taken 2298697 times.
✓ Branch 4 taken 170808 times.
✓ Branch 5 taken 3821706 times.
7248283 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2149
2150 // Stone of Agony
2151 7321601 bool agony=false;
2152 7321601 int32_t agonyid = current_item_id(itype_agony);
2153
2154
2/2
✓ Branch 0 taken 73318 times.
✓ Branch 1 taken 7248283 times.
7321601 if(!invisible)
2155 {
2156
2/2
✓ Branch 0 taken 7004469 times.
✓ Branch 1 taken 243814 times.
7248283 if(agonyid>-1)
2157 {
2158 243814 int32_t power=itemsbuf[agonyid].power;
2159 243814 int32_t left=static_cast<int32_t>(x+8-power)&0xF0; // Check top-left pixel of each tile
2160 243814 int32_t right=(static_cast<int32_t>(x+8+power)&0xF0)+16;
2161 243814 int32_t top=static_cast<int32_t>(y+(bigHitbox ? 8 : 12)-power)&0xF0;
2162 243814 int32_t bottom=(static_cast<int32_t>(y+(bigHitbox ? 8 : 12)+power)&0xF0)+16;
2163
2164
2/2
✓ Branch 0 taken 243814 times.
✓ Branch 1 taken 243814 times.
487628 for(int32_t x=left; x<right; x+=16)
2165 {
2166
2/2
✓ Branch 0 taken 243782 times.
✓ Branch 1 taken 243814 times.
487596 for(int32_t y=top; y<bottom; y+=16)
2167 {
2168
4/4
✓ Branch 0 taken 243798 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 243782 times.
243814 if(agonyflag(MAPFLAG(x, y)) || agonyflag(MAPCOMBOFLAG(x, y)))
2169 {
2170 32 agony=true;
2171 32 x=right; // Break out of outer loop
2172 32 break;
2173 }
2174 243782 }
2175 243814 }
2176 243814 }
2177
2178 7248283 cs = 6;
2179
1/2
✓ Branch 0 taken 7248283 times.
✗ Branch 1 not taken.
7248283 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2180
2/2
✓ Branch 0 taken 1301062 times.
✓ Branch 1 taken 5947221 times.
7248283 if(!get_bit(quest_rules,qr_HEROFLICKER))
2181 {
2182
3/4
✓ Branch 0 taken 96370 times.
✓ Branch 1 taken 5850851 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96370 times.
5947221 if(superman && getCanFlicker())
2183 {
2184 96370 cs += (((~frame)>>1)&3);
2185 96370 }
2186
4/6
✓ Branch 0 taken 239161 times.
✓ Branch 1 taken 5611690 times.
✓ Branch 2 taken 239161 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 239161 times.
5850851 else if(hclk&&(DivineProtectionShieldClk<=0) && getCanFlicker())
2187 {
2188 239161 cs += ((hclk>>1)&3);
2189 239161 }
2190 5947221 }
2191 7248283 }
2192
2193
5/6
✓ Branch 0 taken 6549619 times.
✓ Branch 1 taken 771982 times.
✓ Branch 2 taken 6543817 times.
✓ Branch 3 taken 5802 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6543817 times.
7321601 if(attackclk || (action==attacking||action==sideswimattacking))
2194 {
2195 /* Spaghetti code constants!
2196 * - Hero.attack contains a weapon type...
2197 * - which must be converted to an itype...
2198 * - which must be converted to an item ID...
2199 * - which is used to acquire a wpn ID! Aack!
2200 */
2201
8/8
✓ Branch 0 taken 12859 times.
✓ Branch 1 taken 764925 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 764897 times.
✓ Branch 4 taken 21498 times.
✓ Branch 5 taken 743399 times.
✓ Branch 6 taken 22079 times.
✓ Branch 7 taken 721320 times.
777784 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : attack==wBugNet ? itype_bugnet : itype_sword);
2202
4/4
✓ Branch 0 taken 29427 times.
✓ Branch 1 taken 748357 times.
✓ Branch 2 taken 907 times.
✓ Branch 3 taken 28520 times.
777784 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
2203 777784 itemid=vbound(itemid, 0, MAXITEMS-1);
2204 // if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
2205
7/8
✓ Branch 0 taken 250868 times.
✓ Branch 1 taken 526916 times.
✓ Branch 2 taken 250868 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162452 times.
✓ Branch 5 taken 88416 times.
✓ Branch 6 taken 13522 times.
✓ Branch 7 taken 148930 times.
777784 if(attackclk>4||attack==wBugNet||(attack==wSword&&game->get_canslash()))
2206 {
2207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 540438 times.
540438 if(attack == wBugNet)
2208 {
2209 weapon *w=NULL;
2210 bool found = false;
2211 for(int32_t q = 0; q < Lwpns.Count(); ++q)
2212 {
2213 w = (weapon*)Lwpns.spr(q);
2214 if(w->id == wBugNet)
2215 {
2216 found = true;
2217 break;
2218 }
2219 }
2220 if(!found)
2221 {
2222 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wBugNet,0,0,dir,itemid,getUID(),false,false,true));
2223
2224 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2225 }
2226 positionNet(w, itemid);
2227 }
2228
8/8
✓ Branch 0 taken 133070 times.
✓ Branch 1 taken 407368 times.
✓ Branch 2 taken 117716 times.
✓ Branch 3 taken 15354 times.
✓ Branch 4 taken 108841 times.
✓ Branch 5 taken 8875 times.
✓ Branch 6 taken 117696 times.
✓ Branch 7 taken 422742 times.
540438 else if((attack==wSword || attack==wWand || ((attack==wFire || attack==wCByrna) && itemsbuf[itemid].wpn)) && wpnsbuf[itemsbuf[itemid].wpn].tile)
2229 {
2230 // Create a sword weapon at the right spot.
2231 422742 weapon *w=NULL;
2232 422742 bool found = false;
2233
2234 // Look for pre-existing sword
2235
2/2
✓ Branch 0 taken 41309 times.
✓ Branch 1 taken 488537 times.
529846 for(int32_t i=0; i<Lwpns.Count(); i++)
2236 {
2237 488537 w = (weapon*)Lwpns.spr(i);
2238
2239
2/2
✓ Branch 0 taken 107104 times.
✓ Branch 1 taken 381433 times.
488537 if(w->id == (attack==wSword ? wSword : wWand))
2240 {
2241 381433 found = true;
2242 381433 break;
2243 }
2244 107104 }
2245
2246
2/2
✓ Branch 0 taken 381433 times.
✓ Branch 1 taken 41309 times.
422742 if(!found) // Create one if sword nonexistant
2247 {
2248
5/10
✓ Branch 0 taken 41309 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41309 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41309 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 41309 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 41309 times.
✗ Branch 9 not taken.
41309 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,(attack==wSword ? wSword : wWand),0,0,dir,itemid,getUID(),false,false,true));
2249 41309 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2250
2251 41309 positionSword(w,itemid);
2252
2253 // Stone of Agony
2254
1/2
✓ Branch 0 taken 41309 times.
✗ Branch 1 not taken.
41309 if(agony)
2255 {
2256 w->y-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,2))?1:0;
2257 }
2258 41309 }
2259
2260 // These are set by positionSword(), above or in checkstab()
2261 422742 yofs += slashyofs;
2262 422742 xofs += slashxofs;
2263 422742 slashyofs = slashxofs = 0;
2264 422742 }
2265 540438 }
2266
2267 777784 if(attackclk<7
2268
4/4
✓ Branch 0 taken 412164 times.
✓ Branch 1 taken 365620 times.
✓ Branch 2 taken 313895 times.
✓ Branch 3 taken 98269 times.
777784 || (attack==wSword && ((attackclk<(game->get_canslash()?15:13)
2269
4/6
✓ Branch 0 taken 72650 times.
✓ Branch 1 taken 241245 times.
✓ Branch 2 taken 72650 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 72650 times.
313895 || FIXED_Z3_ANIMATION && attackclk<(game->get_canslash()?16:12))
2270
2/2
✓ Branch 0 taken 1813 times.
✓ Branch 1 taken 70837 times.
72650 || (charging>0 && attackclk!=SWORDCHARGEFRAME)))
2271
4/4
✓ Branch 0 taken 158442 times.
✓ Branch 1 taken 10664 times.
✓ Branch 2 taken 151559 times.
✓ Branch 3 taken 6883 times.
170919 || ((attack==wWand || attack==wFire || attack==wCByrna) && attackclk<13)
2272
4/4
✓ Branch 0 taken 12929 times.
✓ Branch 1 taken 156177 times.
✓ Branch 2 taken 17518 times.
✓ Branch 3 taken 138659 times.
169106 || (attack==wHammer && attackclk<=30)
2273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138659 times.
156177 || (attack==wBugNet && attackclk<NET_CLK_TOTAL))
2274 {
2275
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 639042 times.
639125 if(!invisible)
2276 {
2277 639042 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimstab:ls_stab, dir, zinit.heroAnimationStyle);
2278
2/4
✓ Branch 0 taken 639042 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 639042 times.
✗ Branch 3 not taken.
639042 if (FIXED_Z3_ANIMATION)
2279 {
2280 if (attackclk >= 2) tile += (extend==2?2:1);
2281 if (attackclk >= 13) tile += (extend==2?2:1);
2282 }
2283
2284
14/18
✓ Branch 0 taken 58722 times.
✓ Branch 1 taken 580320 times.
✓ Branch 2 taken 13042 times.
✓ Branch 3 taken 45680 times.
✓ Branch 4 taken 5786 times.
✓ Branch 5 taken 7256 times.
✓ Branch 6 taken 4967 times.
✓ Branch 7 taken 819 times.
✓ Branch 8 taken 41282 times.
✓ Branch 9 taken 17440 times.
✓ Branch 10 taken 23091 times.
✓ Branch 11 taken 18191 times.
✓ Branch 12 taken 23091 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 23091 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
639042 if(((game->get_canslash() && (attack==wSword || attack==wWand || attack==wFire || attack==wCByrna)) && itemsbuf[itemid].flags&ITEM_FLAG4 && (attackclk<7||FIXED_Z3_ANIMATION&&(attackclk < 16))))
2285 {
2286 18191 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2287
2/4
✓ Branch 0 taken 18191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18191 times.
✗ Branch 3 not taken.
18191 if (FIXED_Z3_ANIMATION)
2288 {
2289 if (attackclk >= 7) tile += (extend==2?2:1);
2290 if (attackclk >= 11) tile += (extend==2?2:1);
2291 if (attackclk >= 14) tile += (extend==2?2:1);
2292 }
2293 18191 }
2294
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 639042 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
639042 if (attack==wBugNet && !get_bit(quest_rules, qr_OLD_BUG_NET))
2295 {
2296 if ((dir == right && (itemsbuf[itemid].flags&ITEM_FLAG2)) || (dir != right && !(itemsbuf[itemid].flags&ITEM_FLAG2)))
2297 {
2298 if (attackclk < 9) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2299 if (attackclk > 15) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2300 }
2301 else
2302 {
2303 if (attackclk < 9) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2304 if (attackclk > 15) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2305 }
2306 }
2307
2308
4/4
✓ Branch 0 taken 22079 times.
✓ Branch 1 taken 616963 times.
✓ Branch 2 taken 13029 times.
✓ Branch 3 taken 9050 times.
639042 if((attack==wHammer) && (attackclk<13))
2309 {
2310 9050 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimpound:ls_pound, dir, zinit.heroAnimationStyle);
2311
2/4
✓ Branch 0 taken 9050 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9050 times.
✗ Branch 3 not taken.
9050 if (FIXED_Z3_ANIMATION)
2312 {
2313 if (attackclk >= 14) tile += (extend==2?2:1);
2314 if (attackclk >= 16) tile += (extend==2?2:1);
2315 }
2316 9050 }
2317
2318
2/2
✓ Branch 0 taken 586541 times.
✓ Branch 1 taken 52501 times.
639042 if(useltm)
2319 {
2320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52501 times.
52501 if ( script_hero_sprite <= 0 ) tile+=getTileModifier();
2321 52501 }
2322
2323 // Stone of Agony
2324
1/2
✓ Branch 0 taken 639042 times.
✗ Branch 1 not taken.
639042 if(agony)
2325 {
2326 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2327 }
2328
2329 //Probably what makes Hero flicker, except for the QR check. What makes him flicker when that rule is off?! -Z
2330
2331 //I'm pretty sure he doesn't flicker when the rule is off. Also, take note of the parenthesis after the ! in this if statement; I was blind and didn't see it, and thought this code did something completely different. -Deedee
2332
6/6
✓ Branch 0 taken 137706 times.
✓ Branch 1 taken 501336 times.
✓ Branch 2 taken 134100 times.
✓ Branch 3 taken 3606 times.
✓ Branch 4 taken 11476 times.
✓ Branch 5 taken 126230 times.
639042 if (!(get_bit(quest_rules, qr_HEROFLICKER) && ((superman || hclk) && (frame & 1))))
2333 {
2334 627566 masked_draw(dest);
2335 627566 }
2336
2337 //Prevent flickering -Z
2338
1/2
✓ Branch 0 taken 639042 times.
✗ Branch 1 not taken.
639042 if (!getCanFlicker()) masked_draw(dest);
2339 639042 }
2340
2341
2/2
✓ Branch 0 taken 617046 times.
✓ Branch 1 taken 22079 times.
639125 if(attack!=wHammer)
2342 617046 goto herodraw_end;
2343 22079 }
2344
2345
2/2
✓ Branch 0 taken 22079 times.
✓ Branch 1 taken 138659 times.
160738 if(attack==wHammer) // To do: possibly abstract this out to a positionHammer routine?
2346 {
2347 22079 int32_t wy=1;
2348 22079 int32_t wx=1;
2349 22079 int32_t f=0,t,cs2;
2350 22079 weapon *w=NULL;
2351 22079 bool found = false;
2352
2353
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 21549 times.
22314 for(int32_t i=0; i<Lwpns.Count(); i++)
2354 {
2355 21549 w = (weapon*)Lwpns.spr(i);
2356
2357
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 21314 times.
21549 if(w->id == wHammer)
2358 {
2359 21314 found = true;
2360 21314 break;
2361 }
2362 235 }
2363
2364
2/2
✓ Branch 0 taken 21314 times.
✓ Branch 1 taken 765 times.
22079 if(!found)
2365 {
2366
5/10
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 765 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 765 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 765 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 765 times.
✗ Branch 9 not taken.
765 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wHammer,0,0,dir,itemid,getUID(),false,false,true));
2367 765 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2368 765 found = true;
2369 765 }
2370
2371 22079 t = w->o_tile;
2372 22079 cs2 = w->o_cset;
2373
2374
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3412 times.
✓ Branch 2 taken 4870 times.
✓ Branch 3 taken 6386 times.
✓ Branch 4 taken 7411 times.
22079 switch(dir)
2375 {
2376 case up:
2377 3412 wx=-1;
2378 3412 wy=-15;
2379
1/2
✓ Branch 0 taken 3412 times.
✗ Branch 1 not taken.
3412 if (IsSideSwim())wy+=hammer_swim_up_offset;
2380
2381
2/2
✓ Branch 0 taken 1402 times.
✓ Branch 1 taken 2010 times.
3412 if(attackclk>=13)
2382 {
2383 2010 wx-=1;
2384 2010 wy+=1;
2385 2010 ++t;
2386 2010 }
2387
2388
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1778 times.
3412 if(attackclk>=15)
2389 {
2390
1/2
✓ Branch 0 taken 1778 times.
✗ Branch 1 not taken.
1778 if (IsSideSwim())wy-=hammer_swim_up_offset;
2391 1778 ++t;
2392 1778 }
2393
2394 3412 break;
2395
2396 case down:
2397 4870 wx=3;
2398 4870 wy=-14;
2399
1/2
✓ Branch 0 taken 4870 times.
✗ Branch 1 not taken.
4870 if (IsSideSwim())wy+=hammer_swim_down_offset;
2400 4870 t+=3;
2401
2402
2/2
✓ Branch 0 taken 2021 times.
✓ Branch 1 taken 2849 times.
4870 if(attackclk>=13)
2403 {
2404 2849 wy+=16;
2405 2849 ++t;
2406 2849 }
2407
2408
2/2
✓ Branch 0 taken 2344 times.
✓ Branch 1 taken 2526 times.
4870 if(attackclk>=15)
2409 {
2410 2526 wx-=1;
2411 2526 wy+=12;
2412
1/2
✓ Branch 0 taken 2526 times.
✗ Branch 1 not taken.
2526 if (IsSideSwim())wy-=hammer_swim_down_offset;
2413 2526 ++t;
2414 2526 }
2415
2416 4870 break;
2417
2418 case left:
2419 6386 wx=0;
2420 6386 wy=-14;
2421
1/2
✓ Branch 0 taken 6386 times.
✗ Branch 1 not taken.
6386 if (IsSideSwim())wy+=hammer_swim_left_offset;
2422 6386 t+=6;
2423 6386 f=1;
2424
2425
2/2
✓ Branch 0 taken 2562 times.
✓ Branch 1 taken 3824 times.
6386 if(attackclk>=13)
2426 {
2427 3824 wx-=7;
2428 3824 wy+=8;
2429 3824 ++t;
2430 3824 }
2431
2432
2/2
✓ Branch 0 taken 2986 times.
✓ Branch 1 taken 3400 times.
6386 if(attackclk>=15)
2433 {
2434 3400 wx-=8;
2435 3400 wy+=8;
2436
1/2
✓ Branch 0 taken 3400 times.
✗ Branch 1 not taken.
3400 if (IsSideSwim())wy-=hammer_swim_left_offset;
2437 3400 ++t;
2438 3400 }
2439
2440 6386 break;
2441
2442 case right:
2443 7411 wx=0;
2444 7411 wy=-14;
2445
1/2
✓ Branch 0 taken 7411 times.
✗ Branch 1 not taken.
7411 if (IsSideSwim())wy+=hammer_swim_right_offset;
2446 7411 t+=6;
2447
2448
2/2
✓ Branch 0 taken 3065 times.
✓ Branch 1 taken 4346 times.
7411 if(attackclk>=13)
2449 {
2450 4346 wx+=7;
2451 4346 wy+=8;
2452 4346 ++t;
2453 4346 }
2454
2455
2/2
✓ Branch 0 taken 3558 times.
✓ Branch 1 taken 3853 times.
7411 if(attackclk>=15)
2456 {
2457 3853 wx+=8;
2458 3853 wy+=8;
2459
1/2
✓ Branch 0 taken 3853 times.
✗ Branch 1 not taken.
3853 if (IsSideSwim())wy-=hammer_swim_right_offset;
2460 3853 ++t;
2461 3853 }
2462
2463 7411 break;
2464 }
2465
2466
7/8
✓ Branch 0 taken 21929 times.
✓ Branch 1 taken 150 times.
✓ Branch 2 taken 18085 times.
✓ Branch 3 taken 3844 times.
✓ Branch 4 taken 18085 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1927 times.
✓ Branch 7 taken 16158 times.
22079 if(BSZ || ((isdungeon() && currscr<128) && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)))
2467 {
2468 16308 wy+=2;
2469 16308 }
2470
2471 // Stone of Agony
2472
1/2
✓ Branch 0 taken 22079 times.
✗ Branch 1 not taken.
22079 if(agony)
2473 {
2474 wy-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2475 }
2476
2477 22079 w->x = x+wx;
2478 22079 w->y = y+wy-(54-yofs)-fakez;
2479 22079 w->z = (z+zofs);
2480 22079 w->tile = t;
2481 22079 w->flip = f;
2482 22079 w->hxsz=20;
2483 22079 w->hysz=20;
2484
2485
2/2
✓ Branch 0 taken 13797 times.
✓ Branch 1 taken 8282 times.
22079 if(dir>down)
2486 {
2487 13797 w->hysz-=6;
2488 13797 }
2489 else
2490 {
2491 8282 w->hxsz-=6;
2492 8282 w->hyofs=4;
2493 }
2494
2495 22079 w->power = weaponattackpower(itemid);
2496
2497
7/10
✓ Branch 0 taken 734 times.
✓ Branch 1 taken 21345 times.
✓ Branch 2 taken 734 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 734 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 732 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
22079 if(attackclk==15 && z==0 && fakez==0 && (sideviewhammerpound() || !isSideViewHero()))
2498 {
2499
3/4
✓ Branch 0 taken 722 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 734 times.
✗ Branch 3 not taken.
734 sfx(((iswaterex(MAPCOMBO(x+wx+8,y+wy), currmap, currscr, -1, x+wx+8, y+wy, true) || COMBOTYPE(x+wx+8,y+wy)==cSHALLOWWATER) && get_bit(quest_rules,qr_MORESOUNDS)) ? WAV_ZN1SPLASH : itemsbuf[itemid].usesound,pan(x.getInt()));
2500 734 }
2501
2502 22079 goto herodraw_end;
2503 }
2504 138659 }
2505
2/4
✓ Branch 0 taken 6543817 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6543817 times.
6543817 else if(!charging && !spins) // remove the sword
2506 {
2507
2/2
✓ Branch 0 taken 1720460 times.
✓ Branch 1 taken 6543817 times.
8264277 for(int32_t i=0; i<Lwpns.Count(); i++)
2508 {
2509 1720460 weapon *w = (weapon*)Lwpns.spr(i);
2510
2511
6/6
✓ Branch 0 taken 1719686 times.
✓ Branch 1 taken 774 times.
✓ Branch 2 taken 1719576 times.
✓ Branch 3 taken 110 times.
✓ Branch 4 taken 17390 times.
✓ Branch 5 taken 1702186 times.
1720460 if(w->id == wSword || w->id == wHammer || w->id==wWand)
2512 18274 w->dead=1;
2513 1720460 }
2514 6543817 }
2515
2516
2/2
✓ Branch 0 taken 73235 times.
✓ Branch 1 taken 6609241 times.
6682476 if(invisible)
2517 {
2518 73235 goto herodraw_end;
2519 }
2520
2521
2/4
✓ Branch 0 taken 6609241 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6609241 times.
6609241 if(action != casting && action != sideswimcasting)
2522 {
2523 // Keep this consistent with checkspecial2, line 7800-ish...
2524
6/6
✓ Branch 0 taken 156151 times.
✓ Branch 1 taken 6453090 times.
✓ Branch 2 taken 149362 times.
✓ Branch 3 taken 6789 times.
✓ Branch 4 taken 7237 times.
✓ Branch 5 taken 142125 times.
6609241 bool inwater = iswaterex(MAPCOMBO(x+4,y+9), currmap, currscr, -1, x+4, y+9, true, false) && iswaterex(MAPCOMBO(x+4,y+15), currmap, currscr, -1, x+4, y+15, true, false) && iswaterex(MAPCOMBO(x+11,y+9), currmap, currscr, -1, x+11, y+9, true, false) && iswaterex(MAPCOMBO(x+11,y+15), currmap, currscr, -1, x+11, y+15, true, false);
2525
2526 6609241 int32_t jumping2 = int32_t(jumping*((zinit.gravity2 / 100)/16.0));
2527 6609241 bool noliftspr = get_bit(quest_rules,qr_NO_LIFT_SPRITE);
2528 //if (jumping!=0) al_trace("%d %d %f %d\n",jumping,zinit.gravity,zinit.gravity/16.0,jumping2);
2529
2/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6152181 times.
✓ Branch 3 taken 457060 times.
6609241 switch(zinit.heroAnimationStyle)
2530 {
2531 case las_original: //normal
2532
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 6152117 times.
6152181 if(action==drowning)
2533 {
2534
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(inwater)
2535 {
2536 64 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2538 64 }
2539 else
2540 {
2541 goto herodraw_end;
2542 }
2543 64 }
2544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6152117 times.
6152117 else if(action==lavadrowning)
2545 {
2546 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2547 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2548 }
2549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6152117 times.
6152117 else if(action==sidedrowning)
2550 {
2551 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2552 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2553 }
2554
2/4
✓ Branch 0 taken 6152117 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6152117 times.
6152117 else if (action == sideswimming || action == sideswimhit)
2555 {
2556 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2557
2558 if(lstep>=6)
2559 {
2560 if(dir==up)
2561 {
2562 if ( script_hero_sprite <= 0 ) ++flip;
2563 }
2564 else
2565 {
2566 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2567 }
2568 }
2569 }
2570
5/6
✓ Branch 0 taken 6080680 times.
✓ Branch 1 taken 71437 times.
✓ Branch 2 taken 6080160 times.
✓ Branch 3 taken 520 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6080160 times.
6152117 else if(action==swimming || action==swimhit || hopclk==0xFF)
2571 {
2572 71957 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2573
2574
2/2
✓ Branch 0 taken 35932 times.
✓ Branch 1 taken 36025 times.
71957 if(lstep>=6)
2575 {
2576
2/2
✓ Branch 0 taken 7125 times.
✓ Branch 1 taken 28900 times.
36025 if(dir==up)
2577 {
2578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7125 times.
7125 if ( script_hero_sprite <= 0 ) ++flip;
2579 7125 }
2580 else
2581 {
2582
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 28900 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28900 times.
28900 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2583 }
2584 36025 }
2585
2586
2/2
✓ Branch 0 taken 68768 times.
✓ Branch 1 taken 3189 times.
71957 if(isDiving())
2587 {
2588 3189 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3189 times.
3189 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2590 3189 }
2591 71957 }
2592
3/4
✓ Branch 0 taken 1618 times.
✓ Branch 1 taken 6078542 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1618 times.
6080160 else if(charging > 0 && attack != wHammer)
2593 {
2594 1618 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2595
2596
2/2
✓ Branch 0 taken 943 times.
✓ Branch 1 taken 675 times.
1618 if(lstep>=6)
2597 {
2598
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 144 times.
675 if(dir==up)
2599 {
2600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if ( script_hero_sprite <= 0 ) ++flip;
2601 144 }
2602 else
2603 {
2604
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 531 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 531 times.
531 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2605 }
2606 675 }
2607 1618 }
2608
9/12
✓ Branch 0 taken 6078300 times.
✓ Branch 1 taken 242 times.
✓ Branch 2 taken 6078300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 85805 times.
✓ Branch 5 taken 5992737 times.
✓ Branch 6 taken 71761 times.
✓ Branch 7 taken 14044 times.
✓ Branch 8 taken 71761 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 71761 times.
6078542 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0 && action!=rafting)
2609 {
2610 71761 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71761 times.
71761 if ( script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2612 71761 }
2613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6006781 times.
6006781 else if(fallclk>0)
2614 {
2615 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2616 if ( script_hero_sprite <= 0 ) tile+=((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2617 }
2618
3/6
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 6006165 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 616 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6006781 else if(!noliftspr&&action==lifting&&isLifting())
2619 {
2620 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2621 if(script_hero_sprite <= 0)
2622 {
2623 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2624 auto speed = tliftclk/frames;
2625 if (speed < 1) speed = 1;
2626 auto curframe = (tliftclk - liftclk) / speed;
2627 if (!tliftclk) curframe = frames - 1;
2628 if(unsigned(curframe) < frames)
2629 tile += curframe * (extend == 2 ? 2 : 1);
2630 }
2631 }
2632 else
2633 {
2634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6006781 times.
6006781 if(IsSideSwim())
2635 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2636
3/4
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 6006165 times.
✓ Branch 2 taken 616 times.
✗ Branch 3 not taken.
6006781 else if(!noliftspr&&isLifting())
2637 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2638 6006781 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2639
2640
2/2
✓ Branch 0 taken 4495398 times.
✓ Branch 1 taken 1511383 times.
6006781 if(dir>up)
2641 {
2642 4495398 useltm=true;
2643 4495398 shieldModify=true;
2644 4495398 }
2645
2646
2/2
✓ Branch 0 taken 2931878 times.
✓ Branch 1 taken 3074903 times.
6006781 if(lstep>=6)
2647 {
2648
2/2
✓ Branch 0 taken 764002 times.
✓ Branch 1 taken 2310901 times.
3074903 if(dir==up)
2649 {
2650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 764002 times.
764002 if ( script_hero_sprite <= 0 ) ++flip;
2651 764002 }
2652 else
2653 {
2654
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2310901 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2310901 times.
2310901 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2655 }
2656 3074903 }
2657 }
2658
2659 6152181 break;
2660
2661 case las_bszelda: //BS
2662
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 456484 times.
457060 if(action==drowning)
2663 {
2664
1/2
✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
576 if(inwater)
2665 {
2666 576 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
576 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2668 576 }
2669 else
2670 {
2671 goto herodraw_end;
2672 }
2673 576 }
2674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 456484 times.
456484 else if (action == sidedrowning)
2675 {
2676 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2677 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2678 }
2679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 456484 times.
456484 else if(action==lavadrowning)
2680 {
2681 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2682 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2683 }
2684
2/4
✓ Branch 0 taken 456484 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 456484 times.
456484 else if (action == sideswimming || action == sideswimhit)
2685 {
2686 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2687
2688 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2689 }
2690
4/6
✓ Branch 0 taken 453718 times.
✓ Branch 1 taken 2766 times.
✓ Branch 2 taken 453718 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 453718 times.
456484 else if(action==swimming || action==swimhit || hopclk==0xFF)
2691 {
2692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2766 times.
2766 if (get_bit(quest_rules, qr_COPIED_SWIM_SPRITES))
2693 {
2694 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2695 }
2696 else
2697 {
2698 2766 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2699 }
2700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2766 times.
2766 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2701
2702
2/2
✓ Branch 0 taken 2405 times.
✓ Branch 1 taken 361 times.
2766 if(isDiving())
2703 {
2704
1/2
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
361 if (get_bit(quest_rules, qr_COPIED_SWIM_SPRITES))
2705 {
2706 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2707 }
2708 else
2709 {
2710 361 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2711 }
2712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 361 times.
361 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2713 361 }
2714 2766 }
2715
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 453718 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
453718 else if(charging > 0 && attack != wHammer)
2716 {
2717 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2718 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2719 }
2720
8/10
✓ Branch 0 taken 450239 times.
✓ Branch 1 taken 3479 times.
✓ Branch 2 taken 450239 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3048 times.
✓ Branch 5 taken 450670 times.
✓ Branch 6 taken 2437 times.
✓ Branch 7 taken 611 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2437 times.
453718 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2721 {
2722 2437 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2437 times.
2437 if ( script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2724 2437 }
2725
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 451071 times.
451281 else if(fallclk>0)
2726 {
2727 210 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if ( script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2729 210 }
2730
5/6
✓ Branch 0 taken 28461 times.
✓ Branch 1 taken 422610 times.
✓ Branch 2 taken 109 times.
✓ Branch 3 taken 28352 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 109 times.
451071 else if(!noliftspr&&action==lifting&&isLifting())
2731 {
2732 109 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(script_hero_sprite <= 0)
2734 {
2735 109 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2736 109 auto speed = tliftclk/frames;
2737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if (speed < 1) speed = 1;
2738 109 auto curframe = (tliftclk - liftclk) / speed;
2739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if (!tliftclk) curframe = frames - 1;
2740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(unsigned(curframe) < frames)
2741 109 tile += curframe * (extend == 2 ? 2 : 1);
2742 109 }
2743 109 }
2744 else
2745 {
2746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 450962 times.
450962 if(IsSideSwim())
2747 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2748
4/4
✓ Branch 0 taken 28352 times.
✓ Branch 1 taken 422610 times.
✓ Branch 2 taken 27959 times.
✓ Branch 3 taken 393 times.
450962 else if(!noliftspr&&isLifting())
2749 393 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2750 450569 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2751
2752
2/2
✓ Branch 0 taken 135323 times.
✓ Branch 1 taken 315639 times.
450962 if(dir>up)
2753 {
2754 315639 useltm=true;
2755 315639 shieldModify=true;
2756 315639 }
2757
2758 /*
2759 else if (dir==up)
2760 {
2761 useltm=true;
2762 }
2763 */
2764
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 448402 times.
450962 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2765 }
2766
2767 457060 break;
2768
2769 case las_zelda3slow: //8-frame Zelda 3 (slow)
2770 case las_zelda3: //8-frame Zelda 3
2771 if(action == drowning)
2772 {
2773 if(inwater)
2774 {
2775 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2776 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2777 }
2778 else
2779 {
2780 goto herodraw_end;
2781 }
2782 }
2783 else if(action == lavadrowning)
2784 {
2785 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2786 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2787
2788 }
2789 else if(action == sidedrowning)
2790 {
2791 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2792 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2793 }
2794 else if (action == sideswimming || action == sideswimhit)
2795 {
2796 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2797
2798 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2799 }
2800 else if(action == swimming || action==swimhit || hopclk==0xFF)
2801 {
2802 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2803 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2804
2805 if(isDiving())
2806 {
2807 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2808 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2809 }
2810 }
2811 else if(charging > 0 && attack != wHammer)
2812 {
2813 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2814 if (script_hero_sprite <= 0 ) tile+=(extend==2?2:1);
2815 //int32_t l=hero_count/hero_animation_speed;
2816 int32_t l=(hero_count/hero_animation_speed)&15;
2817 //int32_t l=((p[lt_clock]/hero_animation_speed)&15);
2818 l-=((l>3)?1:0)+((l>12)?1:0);
2819 if (script_hero_sprite <= 0 ) tile+=(l/2)*(extend==2?2:1);
2820 }
2821 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2822 {
2823 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2824 if (script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2825 }
2826 else if(fallclk>0)
2827 {
2828 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2829 if (script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2830 }
2831 else if(!noliftspr&&action==lifting&&isLifting())
2832 {
2833 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2834 if(script_hero_sprite <= 0)
2835 {
2836 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2837 auto speed = tliftclk/frames;
2838 if (speed < 1) speed = 1;
2839 auto curframe = (tliftclk-liftclk)/speed;
2840 if (!tliftclk) curframe = frames - 1;
2841 if(unsigned(curframe) < frames)
2842 tile += curframe * (extend == 2 ? 2 : 1);
2843 }
2844 }
2845 else
2846 {
2847 if(IsSideSwim())
2848 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2849 else if(!noliftspr&&isLifting())
2850 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2851 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2852
2853 if(action == walking || action == climbcoverbottom || action == climbcovertop)
2854 {
2855 if (script_hero_sprite <= 0 ) tile += (extend == 2 ? 2 : 1);
2856 }
2857
2858 if(dir>up)
2859 {
2860 useltm=true;
2861 shieldModify=true;
2862 }
2863
2864 if(action == walking || action == hopping || action == climbcoverbottom || action == climbcovertop)
2865 {
2866 //tile+=(extend==2?2:1);
2867 //tile+=(((active_count>>2)%8)*(extend==2?2:1));
2868 int32_t l = hero_count / hero_animation_speed;
2869 l -= ((l > 3) ? 1 : 0) + ((l > 12) ? 1 : 0);
2870 if (script_hero_sprite <= 0 ) tile += (l / 2) * (extend == 2 ? 2 : 1);
2871 }
2872 }
2873
2874 break;
2875
2876 default:
2877 break;
2878 }
2879 6609241 }
2880
2881
6/6
✓ Branch 0 taken 5704670 times.
✓ Branch 1 taken 904571 times.
✓ Branch 2 taken 3536399 times.
✓ Branch 3 taken 2168271 times.
✓ Branch 4 taken 158886 times.
✓ Branch 5 taken 3377513 times.
6609241 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2882
2883
2/2
✓ Branch 0 taken 6606671 times.
✓ Branch 1 taken 2570 times.
6609241 if(action==won)
2884 {
2885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2570 times.
2570 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - 2;
2886 2570 }
2887
2888
4/4
✓ Branch 0 taken 6563822 times.
✓ Branch 1 taken 45419 times.
✓ Branch 2 taken 48991 times.
✓ Branch 3 taken 6514831 times.
6609241 if(action==landhold1 || action==landhold2)
2889 {
2890 94410 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2891
6/6
✓ Branch 0 taken 80134 times.
✓ Branch 1 taken 14276 times.
✓ Branch 2 taken 59609 times.
✓ Branch 3 taken 20525 times.
✓ Branch 4 taken 13567 times.
✓ Branch 5 taken 46042 times.
94410 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2892 94410 herotile(&tile, &flip, &extend, (action==landhold1)?ls_landhold1:ls_landhold2, dir, zinit.heroAnimationStyle);
2893 94410 }
2894
4/4
✓ Branch 0 taken 6514181 times.
✓ Branch 1 taken 650 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 6514051 times.
6514831 else if(action==waterhold1 || action==waterhold2)
2895 {
2896 780 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2897 780 herotile(&tile, &flip, &extend, (action==waterhold1)?ls_waterhold1:ls_waterhold2, dir, zinit.heroAnimationStyle);
2898 780 }
2899
2/4
✓ Branch 0 taken 6514051 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6514051 times.
6514051 else if(action==sidewaterhold1 || action==sidewaterhold2)
2900 {
2901 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2902 herotile(&tile, &flip, &extend, (action==sidewaterhold1)?ls_sidewaterhold1:ls_sidewaterhold2, dir, zinit.heroAnimationStyle);
2903 }
2904
2905
2/4
✓ Branch 0 taken 6609241 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6609241 times.
6609241 if(action!=casting && action!=sideswimcasting)
2906 {
2907
2/2
✓ Branch 0 taken 1583569 times.
✓ Branch 1 taken 5025672 times.
6609241 if(useltm)
2908 {
2909
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 5023112 times.
5025672 if (script_hero_sprite <= 0 ) tile+=getTileModifier();
2910 5025672 }
2911 6609241 }
2912
2913 // Stone of Agony
2914
2/2
✓ Branch 0 taken 6609209 times.
✓ Branch 1 taken 32 times.
6609241 if(agony)
2915 {
2916
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2917 32 }
2918
2919
6/6
✓ Branch 0 taken 1163356 times.
✓ Branch 1 taken 5445885 times.
✓ Branch 2 taken 1108839 times.
✓ Branch 3 taken 54517 times.
✓ Branch 4 taken 59060 times.
✓ Branch 5 taken 1104296 times.
6609241 if(!(get_bit(quest_rules,qr_HEROFLICKER)&&((superman||hclk)&&(frame&1))))
2920 {
2921 6550181 masked_draw(dest);
2922 6550181 }
2923
2924 //draw held items after Hero so they don't go behind his head
2925
4/4
✓ Branch 0 taken 6563822 times.
✓ Branch 1 taken 45419 times.
✓ Branch 2 taken 48991 times.
✓ Branch 3 taken 6514831 times.
6609241 if(action==landhold1 || action==landhold2)
2926 {
2927
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 94394 times.
94410 if(holditem > -1)
2928 {
2929
2/2
✓ Branch 0 taken 44580 times.
✓ Branch 1 taken 49814 times.
94394 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2930 {
2931 44580 putitem2(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2932 44580 }
2933 else
2934 {
2935 49814 putitem(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2936 }
2937 94394 }
2938 94410 }
2939
4/4
✓ Branch 0 taken 6514181 times.
✓ Branch 1 taken 650 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 6514051 times.
6514831 else if(action==waterhold1 || action==waterhold2)
2940 {
2941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if(holditem > -1)
2942 {
2943
2/2
✓ Branch 0 taken 520 times.
✓ Branch 1 taken 260 times.
780 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2944 {
2945 520 putitem2(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2946 520 }
2947 else
2948 {
2949 260 putitem(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2950 }
2951 780 }
2952 780 }
2953
2/4
✓ Branch 0 taken 6514051 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6514051 times.
6514051 else if(action==sidewaterhold1 || action==sidewaterhold2) //!DIMITODO: Check to see if this looks right or if it needs waterhold's offset.
2954 {
2955 if(holditem > -1)
2956 {
2957 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2958 {
2959 putitem2(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2960 }
2961 else
2962 {
2963 putitem(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2964 }
2965 }
2966 }
2967
4/4
✓ Branch 0 taken 16361 times.
✓ Branch 1 taken 6592880 times.
✓ Branch 2 taken 3393 times.
✓ Branch 3 taken 12968 times.
6609241 if(fairyclk==0||(get_bit(quest_rules,qr_NOHEARTRING)))
2968 {
2969 6596273 goto herodraw_end;
2970 }
2971
2972 12968 double a2 = fairyclk*int64_t(2)*PI/80 + (PI/2);
2973 12968 int32_t hearts=0;
2974 // int32_t htile = QHeader.dat_flags[ZQ_TILES] ? 2 : 0;
2975 12968 int32_t htile = 2;
2976
2977 12968 do
2978 {
2979 80784 int32_t nx=125;
2980
2981
2/2
✓ Branch 0 taken 56544 times.
✓ Branch 1 taken 24240 times.
80784 if(get_bit(quest_rules,qr_HEARTRINGFIX))
2982 {
2983 24240 nx=x;
2984 24240 }
2985
2986 80784 int32_t ny=88;
2987
2988
2/2
✓ Branch 0 taken 56544 times.
✓ Branch 1 taken 24240 times.
80784 if(get_bit(quest_rules,qr_HEARTRINGFIX))
2989 {
2990 24240 ny=y;
2991 24240 }
2992
2993 80784 double tx = zc::math::Cos(a2)*53 +nx;
2994 80784 double ty = -zc::math::Sin(a2)*53 +ny+playing_field_offset;
2995 80784 overtile8(dest,htile,int32_t(tx),int32_t(ty),1,0);
2996 80784 a2-=PI/4;
2997 80784 ++hearts;
2998
2/2
✓ Branch 0 taken 67816 times.
✓ Branch 1 taken 12968 times.
161568 }
2999
2/2
✓ Branch 0 taken 6560 times.
✓ Branch 1 taken 74224 times.
80784 while(a2>PI/2 && hearts<8);
3000 12968 }
3001 herodraw_end:
3002 7324842 xofs=oxofs;
3003 7324842 yofs=oyofs;
3004 7324842 do_primitives(dest, SPLAYER_PLAYER_DRAW, tmpscr, 0, playing_field_offset);
3005 7324842 }
3006
3007 7177747 void HeroClass::masked_draw(BITMAP* dest)
3008 {
3009 7177747 zfix lz, lfz;
3010
2/2
✓ Branch 0 taken 7177245 times.
✓ Branch 1 taken 502 times.
7177747 if(lift_wpn)
3011 {
3012 502 lz = lift_wpn->z;
3013 502 lfz = lift_wpn->fakez;
3014 502 }
3015
3016
12/12
✓ Branch 0 taken 3956081 times.
✓ Branch 1 taken 3221666 times.
✓ Branch 2 taken 3786059 times.
✓ Branch 3 taken 170022 times.
✓ Branch 4 taken 3735765 times.
✓ Branch 5 taken 50294 times.
✓ Branch 6 taken 3681688 times.
✓ Branch 7 taken 54077 times.
✓ Branch 8 taken 3604245 times.
✓ Branch 9 taken 77443 times.
✓ Branch 10 taken 3642303 times.
✓ Branch 11 taken 143756 times.
7177747 if(isdungeon() && currscr<128 && (x<16 || x>224 || y<18 || y>146) && !get_bit(quest_rules,qr_FREEFORM))
3017 {
3018 // clip under doorways
3019 143756 BITMAP *sub=create_sub_bitmap(dest,16,playing_field_offset+16,224,144);
3020
3021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143756 times.
143756 if(sub!=NULL)
3022 {
3023 143756 yofs -= (playing_field_offset+16);
3024 143756 xofs -= 16;
3025 143756 sprite::draw(sub);
3026
1/2
✓ Branch 0 taken 143756 times.
✗ Branch 1 not taken.
143756 if(lift_wpn)
3027 {
3028 handle_lift(false);
3029 bool shad = lift_wpn->has_shadow;
3030 lift_wpn->has_shadow = false;
3031 lift_wpn->z += z;
3032 lift_wpn->fakez += fakez;
3033 lift_wpn->draw(sub);
3034 lift_wpn->has_shadow = shad;
3035 }
3036 143756 prompt_draw(sub);
3037 143756 xofs+=16;
3038 143756 yofs += (playing_field_offset+16);
3039 143756 destroy_bitmap(sub);
3040 143756 }
3041 143756 }
3042 else
3043 {
3044 7033991 sprite::draw(dest);
3045
2/2
✓ Branch 0 taken 7033489 times.
✓ Branch 1 taken 502 times.
7033991 if(lift_wpn)
3046 {
3047 502 handle_lift(false);
3048 502 bool shad = lift_wpn->has_shadow;
3049 502 lift_wpn->has_shadow = false;
3050 502 lift_wpn->z += z;
3051 502 lift_wpn->fakez += fakez;
3052 502 lift_wpn->draw(dest);
3053 502 lift_wpn->has_shadow = shad;
3054 502 }
3055 7033991 prompt_draw(dest);
3056 }
3057
3058
2/2
✓ Branch 0 taken 7177245 times.
✓ Branch 1 taken 502 times.
7177747 if(lift_wpn)
3059 {
3060 502 lift_wpn->z = lz;
3061 502 lift_wpn->fakez = lfz;
3062 502 }
3063 7177747 return;
3064 }
3065 7177747 void HeroClass::prompt_draw(BITMAP* dest)
3066 {
3067
2/2
✓ Branch 0 taken 7175698 times.
✓ Branch 1 taken 2049 times.
7177747 if(!prompt_combo) return;
3068 2049 int32_t sx = real_x(x+xofs+prompt_x);
3069 2049 int32_t sy = real_y(y + yofs + prompt_y) - real_z(z + zofs);
3070 2049 sy -= fake_z(fakez);
3071 2049 overcombo(dest, sx, sy, prompt_combo, prompt_cset);
3072 2049 return;
3073 7177747 }
3074
3075 9357 void collectitem_script(int32_t id)
3076 {
3077
2/2
✓ Branch 0 taken 9243 times.
✓ Branch 1 taken 114 times.
9357 if(itemsbuf[id].collect_script)
3078 {
3079 //clear item script stack.
3080 //ri = &(itemScriptData[id]);
3081 //ri->Clear();
3082 //itemCollectScriptData[id].Clear();
3083 //for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id][q] = 0;
3084 114 ri = &(itemCollectScriptData[id]);
3085
2/2
✓ Branch 0 taken 116736 times.
✓ Branch 1 taken 114 times.
116850 for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id][q] = 0xFFFF;
3086 114 ri->Clear();
3087 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, ((id & 0xFFF)*-1));
3088
3089
2/6
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if ( id > 0 && !(item_collect_doscript[id] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) ) //No collect script on item 0.
3090 {
3091 114 item_collect_doscript[id] = 1;
3092 114 itemscriptInitialised[id] = 0;
3093 114 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, ((id)*-1));
3094 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
3095 114 FFCore.deallocateAllArrays(SCRIPT_ITEM,-(id));
3096 114 }
3097 else if (id == 0 && !(item_collect_doscript[id] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING))) //item 0
3098 {
3099 item_collect_doscript[id] = 1;
3100 itemscriptInitialised[id] = 0;
3101 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, COLLECT_SCRIPT_ITEM_ZERO);
3102 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
3103 FFCore.deallocateAllArrays(SCRIPT_ITEM,COLLECT_SCRIPT_ITEM_ZERO);
3104 }
3105 //runningItemScripts[id] = 0;
3106 114 }
3107 9357 }
3108 934 void passiveitem_script(int32_t id, bool doRun = false)
3109 {
3110 //Passive item scripts on colelction
3111
3/6
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 907 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
934 if(itemsbuf[id].script && ( (itemsbuf[id].flags&ITEM_PASSIVESCRIPT) && (get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING)) ))
3112 {
3113 ri = &(itemScriptData[id]);
3114 for ( int32_t q = 0; q < 1024; q++ ) item_stack[id][q] = 0xFFFF;
3115 ri->Clear();
3116 item_doscript[id] = 1;
3117 itemscriptInitialised[id] = 0;
3118
3119
3120 if(get_bit(quest_rules,qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
3121 && current_item(itemsbuf[id].family) > itemsbuf[id].fam_type)
3122 {
3123 item_doscript[id] = 0;
3124 return;
3125 }
3126 if(doRun)
3127 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].script, id);
3128 }
3129 934 }
3130
3131 // separate case for sword/wand/hammer/slashed weapons only
3132 // the main weapon checking is in the global function check_collisions()
3133 6419565 bool HeroClass::checkstab()
3134 {
3135
14/14
✓ Branch 0 taken 5656188 times.
✓ Branch 1 taken 763377 times.
✓ Branch 2 taken 207362 times.
✓ Branch 3 taken 556015 times.
✓ Branch 4 taken 186080 times.
✓ Branch 5 taken 21282 times.
✓ Branch 6 taken 164001 times.
✓ Branch 7 taken 22079 times.
✓ Branch 8 taken 163973 times.
✓ Branch 9 taken 28 times.
✓ Branch 10 taken 151171 times.
✓ Branch 11 taken 12802 times.
✓ Branch 12 taken 175346 times.
✓ Branch 13 taken 436860 times.
6419565 if(action!=attacking && action!=sideswimattacking || (attack!=wSword && attack!=wWand && attack!=wHammer && attack!=wCByrna && attack!=wFire && attack != wBugNet)
3136 763377 || (attackclk<=4))
3137 5982705 return false;
3138
3139 436860 weapon *w=NULL;
3140
3141 436860 int32_t wx=0,wy=0,wz=0,wxsz=0,wysz=0;
3142 436860 bool found = false;
3143 436860 int32_t melee_weapon_index = 0;
3144 436860 int32_t parentitem=-1;
3145 436860 weapon* meleeweap = nullptr;
3146
2/2
✓ Branch 0 taken 46511 times.
✓ Branch 1 taken 506769 times.
553280 for(int32_t i=0; i<Lwpns.Count(); i++)
3147 {
3148 506769 w = (weapon*)Lwpns.spr(i);
3149
3150
6/6
✓ Branch 0 taken 506731 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 11328 times.
✓ Branch 3 taken 495403 times.
✓ Branch 4 taken 116420 times.
✓ Branch 5 taken 390349 times.
506769 if(w->id == (attack==wCByrna || attack==wFire ? wWand : attack)) // Kludge: Byrna and Candle sticks are wWand-type.
3151 {
3152 390349 found = true;
3153 390349 melee_weapon_index = i+1;
3154 390349 meleeweap = w;
3155 // Position the sword as Hero slashes with it.
3156
3/4
✓ Branch 0 taken 371319 times.
✓ Branch 1 taken 19030 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 371319 times.
390349 if(w->id!=wHammer&&w->id!=wBugNet)
3157 371319 positionSword(w,w->parentitem);
3158
3159 390349 wx=w->x;
3160 390349 wy=w->y;
3161 390349 wz=w->z;
3162 390349 wxsz = w->hxsz;
3163 390349 wysz = w->hysz;
3164 390349 parentitem = w->parentitem;
3165 390349 break;
3166 }
3167 116420 }
3168
3169
6/6
✓ Branch 0 taken 393835 times.
✓ Branch 1 taken 43025 times.
✓ Branch 2 taken 40543 times.
✓ Branch 3 taken 353292 times.
✓ Branch 4 taken 1806 times.
✓ Branch 5 taken 38737 times.
436860 if(attack==wSword && attackclk>=14 && charging==0)
3170 38737 return false;
3171
3172
2/2
✓ Branch 0 taken 351612 times.
✓ Branch 1 taken 46511 times.
398123 if(!found)
3173 46511 return false;
3174
3175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 351612 times.
351612 if(attack == wFire)
3176 return false;
3177
3178
2/2
✓ Branch 0 taken 332582 times.
✓ Branch 1 taken 19030 times.
351612 if(attack==wHammer)
3179 {
3180
2/2
✓ Branch 0 taken 7473 times.
✓ Branch 1 taken 11557 times.
19030 if(attackclk<15)
3181 {
3182
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1152 times.
✓ Branch 2 taken 1702 times.
✓ Branch 3 taken 2090 times.
✓ Branch 4 taken 2529 times.
7473 switch(w->dir)
3183 {
3184 case up:
3185 1152 wx=x-1;
3186 1152 wy=y-4;
3187 1152 break;
3188
3189 case down:
3190 1702 wx=x+8;
3191 1702 wy=y+28;
3192 1702 break; // This is consistent with 2.10
3193
3194 case left:
3195 2090 wx=x-13;
3196 2090 wy=y+14;
3197 2090 break;
3198
3199 case right:
3200 2529 wx=x+21;
3201 2529 wy=y+14;
3202 2529 break;
3203 }
3204
3205
6/8
✓ Branch 0 taken 741 times.
✓ Branch 1 taken 6732 times.
✓ Branch 2 taken 741 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 741 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 739 times.
7473 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
3206 {
3207 //decorations.add(new dHammerSmack((zfix)wx, (zfix)wy, dHAMMERSMACK, 0));
3208 /* The hammer smack sprites weren't being positioned properly if Hero changed directions on the same frame that they are created.
3209 switch(dir)
3210 {
3211 case up:
3212 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
3213 break;
3214
3215 case down:
3216 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
3217 break;
3218
3219 case left:
3220 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
3221 break;
3222
3223 case right:
3224 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
3225 break;
3226 }
3227 */
3228 739 }
3229
3230 7473 return false;
3231 }
3232
2/2
✓ Branch 0 taken 10823 times.
✓ Branch 1 taken 734 times.
11557 else if(attackclk==15)
3233 {
3234 // Hammer's reach needs adjusted slightly for backward compatibility
3235
2/2
✓ Branch 0 taken 620 times.
✓ Branch 1 taken 114 times.
734 if(w->dir==up)
3236 114 w->hyofs-=1;
3237
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 207 times.
620 else if(w->dir==left)
3238 207 w->hxofs-=2;
3239 734 }
3240 11557 }
3241
3242 // The return of Spaghetti Code Constants!
3243
6/6
✓ Branch 0 taken 13622 times.
✓ Branch 1 taken 330517 times.
✓ Branch 2 taken 318942 times.
✓ Branch 3 taken 11575 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 11557 times.
344139 int32_t itype = (attack==wWand ? itype_wand : attack==wSword ? itype_sword : attack==wCByrna ? itype_cbyrna : attack==wBugNet ? itype_bugnet : itype_hammer);
3244
3/4
✓ Branch 0 taken 17374 times.
✓ Branch 1 taken 326765 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17374 times.
344139 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
3245 344139 itemid = vbound(itemid, 0, MAXITEMS-1);
3246
3247 // The sword offsets aren't based on anything other than what felt about right
3248 // compared to the NES game and what mostly kept it from hitting things that
3249 // should clearly be out of range. They could probably still use more tweaking.
3250 // Don't use 2.10 for reference; it's pretty far off.
3251 // - Saf
3252
3253
6/6
✓ Branch 0 taken 34454 times.
✓ Branch 1 taken 309685 times.
✓ Branch 2 taken 5420 times.
✓ Branch 3 taken 29034 times.
✓ Branch 4 taken 8227 times.
✓ Branch 5 taken 26227 times.
344139 if(game->get_canslash() && (attack==wSword || attack==wWand) && itemsbuf[itemid].flags & ITEM_FLAG4)
3254 {
3255
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4253 times.
✓ Branch 2 taken 6662 times.
✓ Branch 3 taken 7800 times.
✓ Branch 4 taken 7512 times.
26227 switch(w->dir)
3256 {
3257 case up:
3258
2/2
✓ Branch 0 taken 2745 times.
✓ Branch 1 taken 1508 times.
4253 if(attackclk<8)
3259 {
3260 1508 wy-=4;
3261 1508 }
3262
3263 4253 break;
3264
3265 case down:
3266 //if(attackclk<8)
3267 {
3268 6662 wy-=2;
3269 }
3270 6662 break;
3271
3272 case left:
3273
3274 //if(attackclk<8)
3275 {
3276 7800 wx+=2;
3277 }
3278
3279 7800 break;
3280
3281 case right:
3282
3283 //if(attackclk<8)
3284 {
3285 7512 wx-=3;
3286 //wy+=((spins>0 || get_bit(quest_rules, qr_SLASHFLIPFIX)) ? -4 : 4);
3287 }
3288
3289 7512 break;
3290 }
3291 26227 }
3292
3293
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 77744 times.
✓ Branch 2 taken 75037 times.
✓ Branch 3 taken 94564 times.
✓ Branch 4 taken 96794 times.
344139 switch(w->dir)
3294 {
3295 case up:
3296 77744 wx+=2;
3297 77744 break;
3298
3299 case down:
3300 75037 break;
3301
3302 case left:
3303 94564 wy-=3;
3304 94564 break;
3305
3306 case right:
3307 96794 wy-=3;
3308 96794 break;
3309 }
3310
3311 344139 wx+=w->hxofs;
3312 344139 wy+=w->hyofs;
3313 344139 wy-=(w->fakez).getInt();
3314
3315
2/2
✓ Branch 0 taken 340961 times.
✓ Branch 1 taken 1702666 times.
2043627 for(int32_t i=0; i<guys.Count(); i++)
3316 {
3317
1/2
✓ Branch 0 taken 1702666 times.
✗ Branch 1 not taken.
1702666 if(attack==wBugNet) break;
3318 // So that Hero can actually hit peahats while jumping, his weapons' hzsz becomes 16 in midair.
3319
6/6
✓ Branch 0 taken 34365 times.
✓ Branch 1 taken 1668301 times.
✓ Branch 2 taken 33886 times.
✓ Branch 3 taken 479 times.
✓ Branch 4 taken 33242 times.
✓ Branch 5 taken 644 times.
1702980 if((guys.spr(i)->hit(wx,wy,wz,wxsz,wysz,wz>0?16:8) && ((attack!=wWand && attack!=wHammer && attack!=wCByrna) || !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3320
5/6
✓ Branch 0 taken 544 times.
✓ Branch 1 taken 1125 times.
✓ Branch 2 taken 1570041 times.
✓ Branch 3 taken 98804 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1668355 times.
1669424 || ((attack==wWand || attack==wCByrna) && guys.spr(i)->hit(wx,wy-8,z,16,24,z>8) && !(itemsbuf[itemid].flags & ITEM_FLAG3))
3321
4/4
✓ Branch 0 taken 47794 times.
✓ Branch 1 taken 1620561 times.
✓ Branch 2 taken 314 times.
✓ Branch 3 taken 47480 times.
1668355 || (attack==wHammer && guys.spr(i)->hit(wx,wy-8,z,16,24,z>0?16:8) && !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3322 {
3323 // Checking the whimsical ring for every collision check causes
3324 // an odd bug. It's much more likely to activate on a 0-damage
3325 // weapon, since a 0-damage hit won't make the enemy invulnerable
3326 // to damaging hits in the following frames.
3327
3328 34367 int32_t whimsyid = current_item_id(itype_whimsicalring);
3329
3330 34367 int32_t dmg = weaponattackpower(itemid);
3331
2/2
✓ Branch 0 taken 32458 times.
✓ Branch 1 taken 1909 times.
34367 if(whimsyid>-1)
3332 {
3333
3/4
✓ Branch 0 taken 1909 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1793 times.
✓ Branch 3 taken 116 times.
1909 if(!(zc_oldrand()%zc_max(itemsbuf[whimsyid].misc1,1)))
3334 116 dmg += current_item_power(itype_whimsicalring);
3335 1793 else whimsyid = -1;
3336 1909 }
3337 34367 int32_t atkringid = current_item_id(itype_atkring);
3338
2/2
✓ Branch 0 taken 34359 times.
✓ Branch 1 taken 8 times.
34367 if(atkringid>-1)
3339 {
3340 8 dmg *= itemsbuf[atkringid].misc2; //Multiplier
3341 8 dmg += itemsbuf[atkringid].misc1; //Additive
3342 8 }
3343
3344 34367 int32_t h = hit_enemy(i,attack,dmg*game->get_hero_dmgmult(),wx,wy,dir,directWpn,w);
3345 34367 enemy *e = (enemy*)guys.spr(i);
3346
2/2
✓ Branch 0 taken 11723 times.
✓ Branch 1 taken 22644 times.
34367 if (h == -1)
3347 {
3348 22644 e->hitby[HIT_BY_LWEAPON] = melee_weapon_index;
3349 22644 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
3350 22644 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
3351
1/2
✓ Branch 0 taken 22644 times.
✗ Branch 1 not taken.
22644 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
3352 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
3353 22644 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
3354 22644 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
3355 22644 } //temp_hit = true; }
3356 //melee weapons and non-melee weapons both writing to this index may be a problem. It needs to be cleared by something earlier than this check.
3357
3358
4/4
✓ Branch 0 taken 22644 times.
✓ Branch 1 taken 11723 times.
✓ Branch 2 taken 22599 times.
✓ Branch 3 taken 45 times.
34367 if(h<0 && whimsyid>-1)
3359 {
3360 45 sfx(itemsbuf[whimsyid].usesound);
3361 45 }
3362
3363
4/4
✓ Branch 0 taken 29804 times.
✓ Branch 1 taken 4563 times.
✓ Branch 2 taken 29710 times.
✓ Branch 3 taken 94 times.
34367 if(h && charging>0)
3364 {
3365 94 attackclk = SWORDTAPFRAME;
3366 94 spins=0;
3367 94 }
3368
3369
8/8
✓ Branch 0 taken 29804 times.
✓ Branch 1 taken 4563 times.
✓ Branch 2 taken 25733 times.
✓ Branch 3 taken 4071 times.
✓ Branch 4 taken 25724 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 25716 times.
34367 if(h && hclk==0 && inlikelike != 1 && !get_bit(quest_rules, qr_DYING_ENEMIES_IGNORE_STUN))
3370 {
3371
2/2
✓ Branch 0 taken 25635 times.
✓ Branch 1 taken 81 times.
25716 if(GuyHit(i,x+7,y+7-fakez,z,2,2,hzsz)!=-1)
3372 {
3373 81 hithero(i);
3374 81 }
3375 25716 }
3376
3377
2/2
✓ Branch 0 taken 31133 times.
✓ Branch 1 taken 3234 times.
34367 if(h==2)
3378 3234 break;
3379 31133 }
3380 1699488 }
3381
3382
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 344065 times.
688334 if(attack == wBugNet
3383
3/4
✓ Branch 0 taken 344139 times.
✓ Branch 1 taken 56 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 344139 times.
344195 || (parentitem==-1&&!get_bit(quest_rules,qr_NOITEMMELEE))
3384
1/2
✓ Branch 0 taken 344139 times.
✗ Branch 1 not taken.
344139 || (parentitem>-1&&!(itemsbuf[parentitem].flags & ITEM_FLAG7)))
3385 {
3386
1/4
✓ Branch 0 taken 344121 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
344121 int32_t bugnetid = attack != wBugNet ? -1 : (parentitem > -1 ? parentitem : current_item_id(itype_bugnet));
3387
2/2
✓ Branch 0 taken 344121 times.
✓ Branch 1 taken 88462 times.
432583 for(int32_t j=0; j<items.Count(); j++)
3388 {
3389 88462 item* ptr = (item*)items.spr(j);
3390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88462 times.
88462 bool dofairy = (attack==wBugNet && itemsbuf[ptr->id].family == itype_fairy)
3391 && (bugnetid > -1 && !(itemsbuf[bugnetid].flags & ITEM_FLAG1));
3392
3393
2/4
✓ Branch 0 taken 88462 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88462 times.
✗ Branch 3 not taken.
88462 if((itemsbuf[ptr->id].family == itype_bottlefill || dofairy) && !game->canFillBottle())
3394 continue; //No picking these up unless you have a bottle to fill!
3395
5/6
✓ Branch 0 taken 88435 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 17604 times.
✓ Branch 3 taken 70831 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17604 times.
88462 if((ptr->pickup & ipCANGRAB) || (ptr->pickup & ipTIMER) || dofairy)
3396 {
3397
7/8
✓ Branch 0 taken 70831 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 30156 times.
✓ Branch 3 taken 40675 times.
✓ Branch 4 taken 40702 times.
✓ Branch 5 taken 30156 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 40702 times.
70858 if(((ptr->pickup & ipCANGRAB) || ptr->clk2 >= 32 || dofairy) && !ptr->fallclk && !ptr->drownclk)
3398 {
3399
6/6
✓ Branch 0 taken 38333 times.
✓ Branch 1 taken 2369 times.
✓ Branch 2 taken 961 times.
✓ Branch 3 taken 37372 times.
✓ Branch 4 taken 38324 times.
✓ Branch 5 taken 2378 times.
79034 if(ptr->hit(wx,wy,z,wxsz,wysz,1) || (attack==wWand && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1))
3400
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 37609 times.
✓ Branch 3 taken 723 times.
38333 || (attack==wHammer && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1)))
3401 {
3402 2378 int32_t pickup = ptr->pickup;
3403 2378 int32_t id2 = ptr->id;
3404 2378 int32_t pstr = ptr->pstring;
3405 2378 int32_t pstr_flags = ptr->pickup_string_flags;
3406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2378 times.
2378 if(!dofairy)
3407 {
3408 2378 std::vector<int32_t> &ev = FFCore.eventData;
3409 2378 ev.clear();
3410 2378 ev.push_back(id2*10000);
3411 2378 ev.push_back(pickup*10000);
3412 2378 ev.push_back(pstr*10000);
3413 2378 ev.push_back(pstr_flags*10000);
3414 2378 ev.push_back(0);
3415 2378 ev.push_back(ptr->getUID());
3416 2378 ev.push_back(GENEVT_ICTYPE_MELEE*10000);
3417 2378 ev.push_back(w->getUID());
3418
3419 2378 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
3420 2378 bool nullify = ev[4] != 0;
3421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2378 times.
2378 if(nullify) continue;
3422 2378 id2 = ev[0]/10000;
3423 2378 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
3424 2378 pstr = ev[2] / 10000;
3425 2378 pstr_flags = ev[3] / 10000;
3426 2378 }
3427
3428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2378 times.
2378 if(pickup&ipONETIME) // set mITEM for one-time-only items
3429 setmapflag(mITEM);
3430
1/2
✓ Branch 0 taken 2378 times.
✗ Branch 1 not taken.
2378 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
3431 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
3432
3433
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2378 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2378 if(ptr->pickupexstate > -1 && ptr->pickupexstate < 32)
3434 setxmapflag(1<<ptr->pickupexstate);
3435
1/2
✓ Branch 0 taken 2378 times.
✗ Branch 1 not taken.
2378 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
3436 {
3437 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
3438 hidden_entrance(0, true, false, -5);
3439 }
3440 //!DIMI
3441
3442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2378 times.
2378 if(dofairy)
3443 {
3444 game->fillBottle(itemsbuf[ptr->id].misc4);
3445 }
3446 else
3447 {
3448 2378 collectitem_script(id2);
3449
3450 2378 getitem(id2, false, true);
3451 }
3452 2378 items.del(j);
3453
3454
2/2
✓ Branch 0 taken 2947 times.
✓ Branch 1 taken 2378 times.
5325 for(int32_t i=0; i<Lwpns.Count(); i++)
3455 {
3456 2947 weapon *w2 = (weapon*)Lwpns.spr(i);
3457
3458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2947 times.
2947 if(w2->dragging==j)
3459 {
3460 w2->dragging=-1;
3461 }
3462
1/2
✓ Branch 0 taken 2947 times.
✗ Branch 1 not taken.
2947 else if(w2->dragging>j)
3463 {
3464 w2->dragging-=1;
3465 }
3466 2947 }
3467
3468
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2378 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2378 if ( (pstr > 0 && pstr < msg_count) )
3469 {
3470 if ( ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
3471 {
3472 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) )
3473 FFCore.SetItemMessagePlayed(id2);
3474 donewmsg(pstr);
3475 break;
3476 }
3477 }
3478
3479 2378 --j;
3480 2378 }
3481 40702 }
3482 70858 }
3483 88462 }
3484 344121 }
3485
3486
3/4
✓ Branch 0 taken 344121 times.
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 344121 times.
344195 if(attack==wCByrna || attack==wBugNet)
3487 74 return false;
3488
3489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344121 times.
344121 if(meleeweap->no_triggers())
3490 return false;
3491
3492
2/2
✓ Branch 0 taken 318942 times.
✓ Branch 1 taken 25179 times.
344121 if(attack==wSword)
3493 {
3494
2/2
✓ Branch 0 taken 279202 times.
✓ Branch 1 taken 39740 times.
318942 if(attackclk == 6)
3495 {
3496
2/2
✓ Branch 0 taken 6994240 times.
✓ Branch 1 taken 39740 times.
7033980 for(int32_t q=0; q<176; q++)
3497 {
3498 6994240 set_bit(screengrid,q,0);
3499 6994240 set_bit(screengrid_layer[0],q,0);
3500 6994240 set_bit(screengrid_layer[1],q,0);
3501 6994240 }
3502
3503
2/2
✓ Branch 0 taken 635840 times.
✓ Branch 1 taken 39740 times.
675580 for(dword q = MAXFFCS/8; q > 0; --q)
3504 635840 ffcgrid[q-1] = 0;
3505 39740 }
3506
3507
4/4
✓ Branch 0 taken 73311 times.
✓ Branch 1 taken 245631 times.
✓ Branch 2 taken 37261 times.
✓ Branch 3 taken 36050 times.
318942 if(dir==up && ((x.getInt()&15)==0))
3508 {
3509 36050 check_slash_block(wx,wy);
3510 36050 check_slash_block(wx,wy+8);
3511
3512 //layers
3513 36050 check_slash_block_layer(wx,wy,1);
3514 36050 check_slash_block_layer(wx,wy+8,1);
3515 36050 check_slash_block_layer(wx,wy,1);
3516 36050 check_slash_block_layer(wx,wy+8,1);
3517 //2
3518 36050 check_slash_block_layer(wx,wy,2);
3519 36050 check_slash_block_layer(wx,wy+8,2);
3520 36050 check_slash_block_layer(wx,wy,2);
3521 36050 check_slash_block_layer(wx,wy+8,2);
3522 36050 }
3523
8/10
✓ Branch 0 taken 37261 times.
✓ Branch 1 taken 245631 times.
✓ Branch 2 taken 1954 times.
✓ Branch 3 taken 35307 times.
✓ Branch 4 taken 155 times.
✓ Branch 5 taken 1799 times.
✓ Branch 6 taken 155 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 155 times.
282892 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3524 {
3525 37106 check_slash_block(wx,wy);
3526 37106 check_slash_block(wx,wy+8);
3527 37106 check_slash_block(wx+8,wy);
3528 37106 check_slash_block(wx+8,wy+8);
3529 ///layer 1
3530 37106 check_slash_block_layer(wx,wy,1);
3531 37106 check_slash_block_layer(wx,wy+8,1);
3532 37106 check_slash_block_layer(wx+8,wy,1);
3533 37106 check_slash_block_layer(wx+8,wy+8,1);
3534 ///layer 2
3535 37106 check_slash_block_layer(wx,wy,2);
3536 37106 check_slash_block_layer(wx,wy+8,2);
3537 37106 check_slash_block_layer(wx+8,wy,2);
3538 37106 check_slash_block_layer(wx+8,wy+8,2);
3539 37106 }
3540
4/4
✓ Branch 0 taken 70549 times.
✓ Branch 1 taken 248393 times.
✓ Branch 2 taken 33993 times.
✓ Branch 3 taken 36556 times.
318942 if(dir==down && ((x.getInt()&15)==0))
3541 {
3542 36556 check_slash_block(wx,wy+wysz-8);
3543 36556 check_slash_block(wx,wy+wysz);
3544
3545 //layer 1
3546 36556 check_slash_block_layer(wx,wy+wysz-8,1);
3547 36556 check_slash_block_layer(wx,wy+wysz,1);
3548 //layer 2
3549 36556 check_slash_block_layer(wx,wy+wysz-8,2);
3550 36556 check_slash_block_layer(wx,wy+wysz,2);
3551 36556 }
3552
8/10
✓ Branch 0 taken 33993 times.
✓ Branch 1 taken 248393 times.
✓ Branch 2 taken 3466 times.
✓ Branch 3 taken 30527 times.
✓ Branch 4 taken 80 times.
✓ Branch 5 taken 3386 times.
✓ Branch 6 taken 80 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 80 times.
282386 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3553 {
3554 33913 check_slash_block(wx,wy+wysz-8);
3555 33913 check_slash_block(wx,wy+wysz);
3556 33913 check_slash_block(wx+8,wy+wysz-8);
3557 33913 check_slash_block(wx+8,wy+wysz);
3558 //layer 1
3559 33913 check_slash_block_layer(wx,wy+wysz-8,1);
3560 33913 check_slash_block_layer(wx,wy+wysz,1);
3561 33913 check_slash_block_layer(wx+8,wy+wysz-8,1);
3562 33913 check_slash_block_layer(wx+8,wy+wysz,1);
3563 //layer 2
3564 33913 check_slash_block_layer(wx,wy+wysz-8,2);
3565 33913 check_slash_block_layer(wx,wy+wysz,2);
3566 33913 check_slash_block_layer(wx+8,wy+wysz-8,2);
3567 33913 check_slash_block_layer(wx+8,wy+wysz,2);
3568 33913 }
3569
3570
2/2
✓ Branch 0 taken 232767 times.
✓ Branch 1 taken 86175 times.
318942 if(dir==left)
3571 {
3572 86175 check_slash_block(wx,wy+8);
3573 86175 check_slash_block(wx+8,wy+8);
3574 //layer 1
3575 86175 check_slash_block_layer(wx,wy+8,1);
3576 86175 check_slash_block_layer(wx+8,wy+8,1);
3577 //layer 2
3578 86175 check_slash_block_layer(wx,wy+8,2);
3579 86175 check_slash_block_layer(wx+8,wy+8,2);
3580 86175 }
3581
3582
2/2
✓ Branch 0 taken 230035 times.
✓ Branch 1 taken 88907 times.
318942 if(dir==right)
3583 {
3584 88907 check_slash_block(wx+wxsz,wy+8);
3585 88907 check_slash_block(wx+wxsz-8,wy+8);
3586 //layer 1
3587 88907 check_slash_block_layer(wx+wxsz,wy+8,1);
3588 88907 check_slash_block_layer(wx+wxsz-8,wy+8,1);
3589 //layer 2
3590 88907 check_slash_block_layer(wx+wxsz,wy+8,2);
3591 88907 check_slash_block_layer(wx+wxsz-8,wy+8,2);
3592 88907 }
3593 318942 }
3594
2/2
✓ Branch 0 taken 13622 times.
✓ Branch 1 taken 11557 times.
25179 else if(attack==wWand)
3595 {
3596
1/2
✓ Branch 0 taken 13622 times.
✗ Branch 1 not taken.
13622 if(attackclk == 5)
3597 {
3598 for(int32_t q=0; q<176; q++)
3599 {
3600 set_bit(screengrid,q,0);
3601 set_bit(screengrid_layer[0],q,0);
3602 set_bit(screengrid_layer[1],q,0);
3603 }
3604
3605 for(dword q = MAXFFCS/8; q > 0; --q)
3606 ffcgrid[q-1] = 0;
3607 }
3608
3609 // cutable blocks
3610
4/4
✓ Branch 0 taken 2662 times.
✓ Branch 1 taken 10960 times.
✓ Branch 2 taken 1464 times.
✓ Branch 3 taken 1198 times.
13622 if(dir==up && (x.getInt()&15)==0)
3611 {
3612 1198 check_wand_block(wx,wy);
3613 1198 check_wand_block(wx,wy+8);
3614 1198 }
3615
5/10
✓ Branch 0 taken 1464 times.
✓ Branch 1 taken 10960 times.
✓ Branch 2 taken 630 times.
✓ Branch 3 taken 834 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 630 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
12424 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3616 {
3617 1464 check_wand_block(wx,wy);
3618 1464 check_wand_block(wx,wy+8);
3619 1464 check_wand_block(wx+8,wy);
3620 1464 check_wand_block(wx+8,wy+8);
3621 1464 }
3622
3623
4/4
✓ Branch 0 taken 1876 times.
✓ Branch 1 taken 11746 times.
✓ Branch 2 taken 824 times.
✓ Branch 3 taken 1052 times.
13622 if(dir==down && (x.getInt()&15)==0)
3624 {
3625 1052 check_wand_block(wx,wy+wysz-8);
3626 1052 check_wand_block(wx,wy+wysz);
3627 1052 }
3628
5/10
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 11746 times.
✓ Branch 2 taken 135 times.
✓ Branch 3 taken 689 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 135 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
12570 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3629 {
3630 824 check_wand_block(wx,wy+wysz-8);
3631 824 check_wand_block(wx,wy+wysz);
3632 824 check_wand_block(wx+8,wy+wysz-8);
3633 824 check_wand_block(wx+8,wy+wysz);
3634 824 }
3635
3636
2/2
✓ Branch 0 taken 8509 times.
✓ Branch 1 taken 5113 times.
13622 if(dir==left)
3637 {
3638 5113 check_wand_block(wx,y+8);
3639 5113 check_wand_block(wx+8,y+8);
3640 5113 }
3641
3642
2/2
✓ Branch 0 taken 9651 times.
✓ Branch 1 taken 3971 times.
13622 if(dir==right)
3643 {
3644 3971 check_wand_block(wx+wxsz,y+8);
3645 3971 check_wand_block(wx+wxsz-8,y+8);
3646 3971 }
3647 13622 }
3648
4/8
✓ Branch 0 taken 11557 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10823 times.
✓ Branch 3 taken 734 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10823 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
11557 else if((attack==wHammer) && ((attackclk==15) || ( spins>0 && attackclk >=15 )))
3649 {
3650 // poundable blocks
3651
2/2
✓ Branch 0 taken 129184 times.
✓ Branch 1 taken 734 times.
129918 for(int32_t q=0; q<176; q++)
3652 {
3653 129184 set_bit(screengrid,q,0);
3654 129184 set_bit(screengrid_layer[0],q,0);
3655 129184 set_bit(screengrid_layer[1],q,0);
3656 129184 }
3657
3658
2/2
✓ Branch 0 taken 11744 times.
✓ Branch 1 taken 734 times.
12478 for(dword q = MAXFFCS/8; q > 0; --q)
3659 11744 ffcgrid[q-1] = 0;
3660
3661
4/4
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 63 times.
734 if(dir==up && (x.getInt()&15)==0)
3662 {
3663 63 check_pound_block(wx,wy);
3664 63 check_pound_block(wx,wy+8);
3665 63 }
3666
3/10
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 618 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 53 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
671 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3667 {
3668 53 check_pound_block(wx,wy);
3669 53 check_pound_block(wx,wy+8);
3670 53 check_pound_block(wx+8,wy);
3671 53 check_pound_block(wx+8,wy+8);
3672 53 }
3673
3674
4/4
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 574 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 95 times.
734 if(dir==down && (x.getInt()&15)==0)
3675 {
3676 95 check_pound_block(wx,wy+wysz-8);
3677 95 check_pound_block(wx,wy+wysz);
3678 95 }
3679
5/10
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 574 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
639 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3680 {
3681 65 check_pound_block(wx,wy+wysz-8);
3682 65 check_pound_block(wx,wy+wysz);
3683 65 check_pound_block(wx+8,wy+wysz-8);
3684 65 check_pound_block(wx+8,wy+wysz);
3685 65 }
3686
3687
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 212 times.
734 if(dir==left)
3688 {
3689 212 check_pound_block(wx,y+8);
3690 212 check_pound_block(wx+8,y+8);
3691 212 }
3692
3693
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 246 times.
734 if(dir==right)
3694 {
3695 246 check_pound_block(wx+wxsz,y+8);
3696 246 check_pound_block(wx+wxsz-8,y+8);
3697 246 }
3698 734 }
3699 10823 else return false;
3700
3701 333298 return true;
3702 6419621 }
3703
3704 1703104 void HeroClass::check_slash_block_layer(int32_t bx, int32_t by, int32_t layer)
3705 {
3706
2/2
✓ Branch 0 taken 1384 times.
✓ Branch 1 taken 1701720 times.
1703104 if(!(get_bit(quest_rules,qr_BUSHESONLAYERS1AND2)))
3707 {
3708 //zprint("bit off\n");
3709 1701720 return;
3710 }
3711 //keep things inside the screen boundaries
3712 1384 bx=vbound(bx, 0, 255);
3713 1384 by=vbound(by, 0, 176);
3714 1384 int32_t fx=vbound(bx, 0, 255);
3715 1384 int32_t fy=vbound(by, 0, 176);
3716 //first things first
3717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1384 times.
1384 if(attack!=wSword)
3718 return;
3719
3720
3/6
✓ Branch 0 taken 1384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1384 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 140 times.
1524 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3721
3/4
✓ Branch 0 taken 1384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
✓ Branch 3 taken 1244 times.
1384 || (attackclk>SWORDTAPFRAME && tapping))
3722 return;
3723
3724 //find out which combo row/column the coordinates are in
3725 1384 bx &= 0xF0;
3726 1384 by &= 0xF0;
3727
3728
3729 1384 int32_t flag = MAPFLAGL(layer,bx,by);
3730 1384 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
3731 1384 int32_t cid = MAPCOMBOL(layer,bx,by);
3732 1384 int32_t type = combobuf[cid].type;
3733
1/2
✓ Branch 0 taken 1384 times.
✗ Branch 1 not taken.
1384 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
3734 type = cNONE;
3735 //zprint("cid is: %d\n", cid);
3736 //zprint("type is: %d\n", type);
3737 1384 int32_t i = (bx>>4) + by;
3738
3739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1384 times.
1384 if(i > 175)
3740 return;
3741
3742 1384 bool ignorescreen=false;
3743
3744
2/4
✓ Branch 0 taken 1384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1384 times.
✗ Branch 3 not taken.
1384 if((get_bit(screengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
3745 1384 return;
3746
3747 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3748
3749 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid_layer[layer-1],i,1);
3750 if(isCuttableNextType(type))
3751 {
3752 FFCore.tempScreens[layer]->data[i]++;
3753 }
3754 else
3755 {
3756 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
3757 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
3758 FFCore.tempScreens[layer]->sflag[i] = 0;
3759 }
3760 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
3761 {
3762 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
3763 sfx(tmpscr->secretsfx);
3764 }
3765 else if(isCuttableItemType(type))
3766 {
3767 int32_t it = -1;
3768 int32_t thedropset = -1;
3769
3770 //select_dropitem( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) ? (combobuf[MAPCOMBO(bx,by)-1].attributes[1])/10000L : 12, bx, by);
3771 if ( (combobuf[cid].usrflags&cflag2) )
3772 {
3773 if(combobuf[cid].usrflags&cflag11)
3774 it = combobuf[cid].attribytes[1];
3775 else
3776 {
3777 it = select_dropitem(combobuf[cid].attribytes[1]);
3778 thedropset = combobuf[cid].attribytes[1];
3779 }
3780 }
3781 else
3782 {
3783 it = select_dropitem(12);
3784 thedropset = 12;
3785 }
3786 if(it!=-1)
3787 {
3788 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
3789 itm->from_dropset = thedropset;
3790 items.add(itm);
3791 }
3792 }
3793
3794 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
3795
3796 if(get_bit(quest_rules,qr_MORESOUNDS))
3797 {
3798 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
3799 {
3800 if (combobuf[cid].usrflags&cflag3)
3801 {
3802 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3803 }
3804 }
3805 else
3806 {
3807 if (combobuf[cid].usrflags&cflag3)
3808 {
3809 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3810 }
3811 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
3812 }
3813 }
3814
3815 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
3816 if(decotype > 3) decotype = 0;
3817 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
3818 switch(decotype)
3819 {
3820 case -2: break; //nothing
3821 case -1:
3822 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
3823 break;
3824 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
3825 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
3826 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
3827 }
3828 1703104 }
3829
3830 779452 void HeroClass::check_slash_block(int32_t bx, int32_t by)
3831 {
3832 //keep things inside the screen boundaries
3833 779452 bx=vbound(bx, 0, 255);
3834 779452 by=vbound(by, 0, 176);
3835 779452 int32_t fx=vbound(bx, 0, 255);
3836 779452 int32_t fy=vbound(by, 0, 176);
3837 //first things first
3838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 779452 times.
779452 if(attack!=wSword)
3839 return;
3840
3841
4/6
✓ Branch 0 taken 779452 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 779452 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 93790 times.
873494 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3842
4/4
✓ Branch 0 taken 775590 times.
✓ Branch 1 taken 3862 times.
✓ Branch 2 taken 94042 times.
✓ Branch 3 taken 681548 times.
779452 || (attackclk>SWORDTAPFRAME && tapping))
3843 4114 return;
3844
3845 //find out which combo row/column the coordinates are in
3846 775338 bx &= 0xF0;
3847 775338 by &= 0xF0;
3848
3849 775338 int cid = MAPCOMBO(bx,by);
3850 775338 int cid_ff = MAPFFCOMBO(x,y);
3851 775338 int current_ffcombo = getFFCAt(fx,fy);
3852 775338 newcombo const& cmb = combobuf[cid];
3853 775338 newcombo const& cmb_ff = combobuf[cid_ff];
3854 775338 int type = cmb.type;
3855 775338 int type2 = cmb_ff.type;
3856 775338 int flag = MAPFLAG(bx,by);
3857 775338 int flag2 = cmb.flag;
3858 775338 int flag3 = cmb_ff.flag;
3859 775338 int i = (bx>>4) + by;
3860
3861
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 775317 times.
775338 if(i > 175)
3862 21 return;
3863
3864 775317 bool ignorescreen=false;
3865 775317 bool ignoreffc=false;
3866
3867
2/2
✓ Branch 0 taken 8211 times.
✓ Branch 1 taken 767106 times.
775317 if(get_bit(screengrid, i) != 0)
3868 {
3869 8211 ignorescreen = true;
3870 8211 }
3871
2/2
✓ Branch 0 taken 767101 times.
✓ Branch 1 taken 5 times.
767106 else if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
3872 5 ignorescreen = true;
3873
3874
3875
3876
3/4
✓ Branch 0 taken 3709 times.
✓ Branch 1 taken 771608 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3709 times.
775317 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
3877 {
3878 771608 ignoreffc = true;
3879 771608 }
3880
2/2
✓ Branch 0 taken 3705 times.
✓ Branch 1 taken 4 times.
3709 else if(cmb_ff.triggerflags[0] & combotriggerONLYGENTRIG)
3881 4 ignoreffc = true;
3882
3883
3/4
✓ Branch 0 taken 771658 times.
✓ Branch 1 taken 3659 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 771613 times.
1546930 if(!isCuttableType(type) &&
3884
6/6
✓ Branch 0 taken 1213 times.
✓ Branch 1 taken 770445 times.
✓ Branch 2 taken 771613 times.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 771568 times.
771658 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
3885 {
3886 771613 ignorescreen = true;
3887 771613 }
3888
3889
3/4
✓ Branch 0 taken 775299 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 775299 times.
1550616 if(!isCuttableType(type2) &&
3890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 775299 times.
775299 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
3891 {
3892 775299 ignoreffc = true;
3893 775299 }
3894
3895 775317 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
3896
3897
3/4
✓ Branch 0 taken 32952 times.
✓ Branch 1 taken 742365 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32952 times.
775317 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3898 775317 byte skipsecrets = 0;
3899
3900
2/2
✓ Branch 0 taken 772807 times.
✓ Branch 1 taken 2510 times.
775317 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
3901 {
3902
2/2
✓ Branch 0 taken 2466 times.
✓ Branch 1 taken 44 times.
2510 if (get_bit(quest_rules,qr_OLD_SLASHNEXT_SECRETS))
3903 {
3904 2466 skipsecrets = 0;
3905 2466 }
3906 44 else skipsecrets = 1; ;
3907 2510 }
3908
3909
6/6
✓ Branch 0 taken 2156 times.
✓ Branch 1 taken 773161 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 2117 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 51 times.
775317 if(!ignorescreen && (!skipsecrets || !get_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS)))
3910 {
3911
5/6
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2103 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 52 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 13 times.
2168 if((flag >= 16)&&(flag <= 31) && !skipsecrets)
3912 {
3913 13 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
3914 13 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
3915 13 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
3916 13 }
3917
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2151 times.
2155 else if(flag == mfARMOS_SECRET)
3918 {
3919 4 s->data[i] = s->secretcombo[sSTAIRS];
3920 4 s->cset[i] = s->secretcset[sSTAIRS];
3921 4 s->sflag[i] = s->secretflag[sSTAIRS];
3922 4 sfx(tmpscr->secretsfx);
3923 4 }
3924
4/4
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 2100 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 2094 times.
2151 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
3925 {
3926
4/4
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 107 times.
✓ Branch 3 taken 45 times.
164 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3927 {
3928 107 findentrance(bx,by,mfSWORD+i2,true);
3929 107 }
3930
3931 45 findentrance(bx,by,mfSTRIKE,true);
3932 45 }
3933
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2094 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2094 else if(((flag2 >= 16)&&(flag2 <= 31)))
3934 {
3935 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
3936 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
3937 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
3938 }
3939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2094 times.
2094 else if(flag2 == mfARMOS_SECRET)
3940 {
3941 s->data[i] = s->secretcombo[sSTAIRS];
3942 s->cset[i] = s->secretcset[sSTAIRS];
3943 s->sflag[i] = s->secretflag[sSTAIRS];
3944 sfx(tmpscr->secretsfx);
3945 }
3946
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2094 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2094 times.
2094 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
3947 {
3948 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3949 {
3950 findentrance(bx,by,mfSWORD+i2,true);
3951 }
3952
3953 findentrance(bx,by,mfSTRIKE,true);
3954 }
3955 else
3956 {
3957
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 1134 times.
2094 if(isCuttableNextType(type))
3958 {
3959 960 s->data[i]++;
3960 960 }
3961 else
3962 {
3963 1134 s->data[i] = s->undercombo;
3964 1134 s->cset[i] = s->undercset;
3965 1134 s->sflag[i] = 0;
3966 }
3967
3968 //pausenow=true;
3969 }
3970 2156 }
3971
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 773173 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
773173 else if(!ignorescreen && skipsecrets)
3972 {
3973 if(isCuttableNextType(type))
3974 {
3975 s->data[i]++;
3976 }
3977 else
3978 {
3979 s->data[i] = s->undercombo;
3980 s->cset[i] = s->undercset;
3981 s->sflag[i] = 0;
3982 }
3983 }
3984
3985
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 775329 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 775329 times.
775329 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
3986 {
3987 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3988 {
3989 findentrance(bx,by,mfSWORD+i2,true);
3990 }
3991
3992 findentrance(fx,fy,mfSTRIKE,true);
3993 }
3994
1/2
✓ Branch 0 taken 775329 times.
✗ Branch 1 not taken.
775329 else if(!ignoreffc)
3995 {
3996 if(isCuttableNextType(type2))
3997 {
3998 s->ffcs[current_ffcombo].incData(1);
3999 }
4000 else
4001 {
4002 s->ffcs[current_ffcombo].setData(s->undercombo);
4003 s->ffcs[current_ffcombo].cset = s->undercset;
4004 }
4005 }
4006
4007
2/2
✓ Branch 0 taken 773173 times.
✓ Branch 1 taken 2156 times.
775329 if(!ignorescreen)
4008 {
4009
4/4
✓ Branch 0 taken 984 times.
✓ Branch 1 taken 1172 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 955 times.
2156 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
4010
4011
8/8
✓ Branch 0 taken 2133 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2134 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 23 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 21 times.
2156 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4012 {
4013
4/8
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
22 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4014 22 sfx(tmpscr->secretsfx);
4015 22 }
4016
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 2086 times.
2134 else if(isCuttableItemType(type))
4017 {
4018 2086 int32_t it = -1;
4019 2086 int32_t thedropset = -1;
4020
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 2064 times.
2086 if ( (cmb.usrflags&cflag2) ) //specific dropset or item
4021 {
4022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if ( cmb.usrflags&cflag11 )
4023 {
4024 it = cmb.attribytes[1];
4025 }
4026 else
4027 {
4028 22 it = select_dropitem(cmb.attribytes[1]);
4029 22 thedropset = cmb.attribytes[1];
4030 }
4031 22 }
4032 else
4033 {
4034 2064 it = select_dropitem(12);
4035 2064 thedropset = 12;
4036 }
4037
4038
2/2
✓ Branch 0 taken 1459 times.
✓ Branch 1 taken 627 times.
2086 if(it!=-1)
4039 {
4040
4/8
✓ Branch 0 taken 627 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 627 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 627 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 627 times.
✗ Branch 7 not taken.
627 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4041 627 itm->from_dropset = thedropset;
4042 627 items.add(itm);
4043 627 }
4044 2086 }
4045
4046 2156 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4047
4048
2/2
✓ Branch 0 taken 1963 times.
✓ Branch 1 taken 193 times.
2156 if(get_bit(quest_rules,qr_MORESOUNDS))
4049 {
4050
6/6
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 44 times.
193 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4051 {
4052
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 22 times.
44 if (cmb.usrflags&cflag3)
4053 {
4054 22 sfx(cmb.attribytes[2],int32_t(bx));
4055 22 }
4056 44 }
4057 else
4058 {
4059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if (cmb.usrflags&cflag3)
4060 {
4061 sfx(cmb.attribytes[2],int32_t(bx));
4062 }
4063 149 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4064 }
4065 193 }
4066
4067
3/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 2036 times.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
2156 int16_t decotype = (cmb.usrflags & cflag1) ? ((cmb.usrflags & cflag10) ? (cmb.attribytes[0]) : (-1)) : (0);
4068
1/2
✓ Branch 0 taken 2156 times.
✗ Branch 1 not taken.
2156 if(decotype > 3) decotype = 0;
4069
7/8
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 2036 times.
✓ Branch 2 taken 350 times.
✓ Branch 3 taken 1686 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1686 times.
✓ Branch 6 taken 553 times.
✓ Branch 7 taken 1133 times.
2156 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((cmb.usrflags & cflag1) ? -1 : -2))));
4070
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1133 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 449 times.
✓ Branch 4 taken 21 times.
✓ Branch 5 taken 553 times.
2156 switch(decotype)
4071 {
4072 1133 case -2: break; //nothing
4073 case -1:
4074 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, cmb.attribytes[0]));
4075 break;
4076
3/6
✓ Branch 0 taken 449 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 449 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 449 times.
✗ Branch 5 not taken.
449 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4077
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4078
3/6
✓ Branch 0 taken 553 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 553 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 553 times.
✗ Branch 5 not taken.
553 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4079 }
4080 2156 }
4081
4082
1/2
✓ Branch 0 taken 775329 times.
✗ Branch 1 not taken.
775329 if(!ignoreffc)
4083 {
4084 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4085
4086 if(isCuttableItemType(type2))
4087 {
4088 int32_t it=-1;
4089 int32_t thedropset=-1;
4090 if ( (cmb_ff.usrflags&cflag2) )
4091 {
4092 if(cmb_ff.usrflags&cflag11)
4093 it = cmb_ff.attribytes[1];
4094 else
4095 {
4096 it = select_dropitem(cmb_ff.attribytes[1]);
4097 thedropset = cmb_ff.attribytes[1];
4098 }
4099 }
4100 else
4101 {
4102 if(get_bit(quest_rules,qr_HARDCODED_FFC_BUSH_DROPS))
4103 {
4104 int32_t r=zc_oldrand()%100;
4105
4106 if(r<15)
4107 it=iHeart; // 15%
4108 else if(r<35)
4109 it=iRupy; // 20%
4110 }
4111 else
4112 {
4113 it = select_dropitem(12);
4114 thedropset = 12;
4115 }
4116 }
4117
4118 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4119 {
4120 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4121 itm->from_dropset = thedropset;
4122 items.add(itm);
4123 }
4124 }
4125
4126 if(get_bit(quest_rules,qr_MORESOUNDS))
4127 {
4128 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4129 {
4130 if (cmb_ff.usrflags&cflag3)
4131 {
4132 sfx(cmb_ff.attribytes[2],int32_t(bx));
4133 }
4134 }
4135 else
4136 {
4137 if (cmb_ff.usrflags&cflag3)
4138 {
4139 sfx(cmb_ff.attribytes[2],int32_t(bx));
4140 }
4141 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4142 }
4143 }
4144
4145 int16_t decotype = (cmb_ff.usrflags & cflag1) ? ((cmb_ff.usrflags & cflag10) ? (cmb_ff.attribytes[0]) : (-1)) : (0);
4146 if(decotype > 3) decotype = 0;
4147 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((cmb_ff.usrflags & cflag1) ? -1 : -2))));
4148 switch(decotype)
4149 {
4150 case -2: break; //nothing
4151 case -1:
4152 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, cmb_ff.attribytes[0]));
4153 break;
4154 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4155 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4156 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4157 }
4158 }
4159 779464 }
4160
4161 13019260 void HeroClass::check_wpn_triggers(int32_t bx, int32_t by, weapon *w)
4162 {
4163 /*
4164 int32_t par_item = w->parentitem;
4165 al_trace("check_wpn_triggers(weapon *w): par_item is: %d\n", par_item);
4166 int32_t usewpn = -1;
4167 if ( par_item > -1 )
4168 {
4169 usewpn = itemsbuf[par_item].useweapon;
4170 }
4171 else if ( par_item == -1 && w->ScriptGenerated )
4172 {
4173 usewpn = w->useweapon;
4174 }
4175 al_trace("check_wpn_triggers(weapon *w): usewpn is: %d\n", usewpn);
4176
4177 */
4178 13019260 bx=vbound(bx, 0, 255);
4179 13019260 by=vbound(by, 0, 176);
4180 13019260 int32_t cid = MAPCOMBO(bx,by);
4181
3/30
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 201168 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 12816844 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 1248 times.
✗ Branch 29 not taken.
13019260 switch(w->useweapon)
4182 {
4183 case wArrow:
4184 findentrance(bx,by,mfARROW,true);
4185 findentrance(bx,by,mfSARROW,true);
4186 findentrance(bx,by,mfGARROW,true);
4187 break;
4188 case wBeam:
4189 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4190 break;
4191 case wHookshot:
4192 findentrance(bx,by,mfHOOKSHOT,true);
4193 break;
4194 case wBrang:
4195 for(int32_t i = 0; i <3; i++) findentrance(bx,by,mfBRANG+i,true);
4196 break;
4197 case wMagic:
4198 findentrance(bx,by,mfWANDMAGIC,true);
4199 break;
4200 case wRefMagic:
4201 findentrance(bx,by,mfWANDMAGIC,true);
4202 break;
4203 case wRefBeam:
4204 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4205 break;
4206 //reflected magic needs to happen in mirrors:
4207 //
4208 //findentrance(bx,by,mfREFMAGIC,true)
4209 case wRefFireball:
4210 findentrance(bx,by,mfREFFIREBALL,true);
4211 break;
4212 case wBomb:
4213 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfBOMB,true);
4214 break;
4215
4216 case wSBomb:
4217 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfSBOMB,true);
4218 break;
4219
4220 case wFire:
4221 201168 findentrance(bx,by,mfANYFIRE,true);
4222 201168 findentrance(bx,by,mfSTRONGFIRE,true);
4223 201168 findentrance(bx,by,mfMAGICFIRE,true);
4224 /* if we want the weapon to die
4225 if (findentrance(bx,by,mfANYFIRE,true) ) dead = 1;
4226 if (findentrance(bx,by,mfSTRONGFIRE,true) ) dead = 1;
4227 if (findentrance(bx,by,mfMAGICFIRE,true)) dead = 1;
4228 */
4229 201168 break;
4230
4231 case wScript1:
4232 break;
4233 case wScript2:
4234 break;
4235 case wScript3:
4236 break;
4237 case wScript4:
4238 break;
4239 case wScript5:
4240 break;
4241 case wScript6:
4242 break;
4243 case wScript7:
4244 break;
4245 case wScript8:
4246 break;
4247 case wScript9:
4248 break;
4249 case wScript10:
4250 break;
4251 case wIce:
4252 break;
4253 case wCByrna:
4254 break;
4255 case wWhistle:
4256 break;
4257 case wSSparkle:
4258 case wFSparkle:
4259 break;
4260 case wWind:
4261 break;
4262 case wBait:
4263 break;
4264 case wFlame:
4265 case wThrown:
4266 case wBombos:
4267 case wEther:
4268 case wQuake:
4269 case wSwordLA:
4270 case wSword180:
4271 case wStomp:
4272 break;
4273 case wSword:
4274 case wWand:
4275 //case wCandle:
4276 case wHSHandle:
4277 case wLitBomb:
4278 case wLitSBomb:
4279 1248 break;
4280 12816844 default: break;
4281
4282 }
4283 13019260 }
4284
4285 26038520 void HeroClass::check_slash_block_layer2(int32_t bx, int32_t by, weapon *w, int32_t layer)
4286 {
4287
4288
2/2
✓ Branch 0 taken 95758 times.
✓ Branch 1 taken 25942762 times.
26038520 if(!(get_bit(quest_rules,qr_BUSHESONLAYERS1AND2)))
4289 {
4290 //zprint("bit off\n");
4291 25942762 return;
4292 }
4293 //keep things inside the screen boundaries
4294 95758 bx=vbound(bx, 0, 255);
4295 95758 by=vbound(by, 0, 176);
4296 95758 int32_t fx=vbound(bx, 0, 255);
4297 95758 int32_t fy=vbound(by, 0, 176);
4298 //first things first
4299
1/2
✓ Branch 0 taken 95758 times.
✗ Branch 1 not taken.
95758 if(w->useweapon != wSword)
4300 95758 return;
4301
4302 //find out which combo row/column the coordinates are in
4303 bx &= 0xF0;
4304 by &= 0xF0;
4305
4306
4307 int32_t flag = MAPFLAGL(layer,bx,by);
4308 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
4309 int32_t cid = MAPCOMBOL(layer,bx,by);
4310 int32_t type = combobuf[cid].type;
4311 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4312 type = cNONE;
4313 //zprint("cid is: %d\n", cid);
4314 //zprint("type is: %d\n", type);
4315 int32_t i = (bx>>4) + by;
4316
4317 if(i > 175)
4318 return;
4319
4320 if((get_bit(w->wscreengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
4321 {
4322 return;
4323 //ignorescreen = true;
4324 //zprint("ignoring\n");
4325 }
4326
4327 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4328
4329 {
4330 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid_layer[layer-1],i,1);
4331 if(isCuttableNextType(type) || isCuttableNextType(type))
4332 {
4333 FFCore.tempScreens[layer]->data[i]++;
4334 }
4335 else
4336 {
4337 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
4338 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
4339 FFCore.tempScreens[layer]->sflag[i] = 0;
4340 }
4341 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4342 {
4343 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4344 sfx(tmpscr->secretsfx);
4345 }
4346 else if(isCuttableItemType(type))
4347 {
4348 int32_t it = -1;
4349 int32_t thedropset = -1;
4350
4351 if ( (combobuf[cid].usrflags&cflag2) )
4352 {
4353 if(combobuf[cid].usrflags&cflag11)
4354 it = combobuf[cid].attribytes[1];
4355 else
4356 {
4357 it = select_dropitem(combobuf[cid].attribytes[1]);
4358 thedropset = combobuf[cid].attribytes[1];
4359 }
4360 }
4361 else
4362 {
4363 it = select_dropitem(12);
4364 thedropset = 12;
4365 }
4366
4367 if(it!=-1)
4368 {
4369 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4370 itm->from_dropset = thedropset;
4371 items.add(itm);
4372 }
4373 }
4374
4375 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
4376
4377 if(get_bit(quest_rules,qr_MORESOUNDS))
4378 {
4379 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4380 {
4381 if (combobuf[cid].usrflags&cflag3)
4382 {
4383 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4384 }
4385 }
4386 else
4387 {
4388 if (combobuf[cid].usrflags&cflag3)
4389 {
4390 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4391 }
4392 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4393 }
4394 }
4395
4396 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4397 if(decotype > 3) decotype = 0;
4398 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4399 switch(decotype)
4400 {
4401 case -2: break; //nothing
4402 case -1:
4403 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4404 break;
4405 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4406 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4407 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4408 }
4409
4410 }
4411
4412 26038520 }
4413
4414 13019260 void HeroClass::check_slash_block2(int32_t bx, int32_t by, weapon *w)
4415 {
4416 /*
4417 int32_t par_item = w->parentitem;
4418 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4419 int32_t usewpn = -1;
4420 if ( par_item > -1 )
4421 {
4422 usewpn = itemsbuf[par_item].useweapon;
4423 }
4424 else if ( par_item == -1 && w->ScriptGenerated )
4425 {
4426 usewpn = w->useweapon;
4427 }
4428 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4429 */
4430
4431
4432 //keep things inside the screen boundaries
4433 13019260 bx=vbound(bx, 0, 255);
4434 13019260 by=vbound(by, 0, 176);
4435 13019260 int32_t fx=vbound(bx, 0, 255);
4436 13019260 int32_t fy=vbound(by, 0, 176);
4437 13019260 int32_t cid = MAPCOMBO(bx,by);
4438
4439 //find out which combo row/column the coordinates are in
4440 13019260 bx &= 0xF0;
4441 13019260 by &= 0xF0;
4442
4443 13019260 int32_t type = COMBOTYPE(bx,by);
4444 13019260 int32_t type2 = FFCOMBOTYPE(fx,fy);
4445 13019260 int32_t flag = MAPFLAG(bx,by);
4446 13019260 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4447 13019260 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4448
2/2
✓ Branch 0 taken 13019046 times.
✓ Branch 1 taken 214 times.
13019260 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4449 214 type = cNONE;
4450 13019260 byte dontignore = 0;
4451 13019260 byte dontignoreffc = 0;
4452
4453
4/4
✓ Branch 0 taken 217832 times.
✓ Branch 1 taken 12801428 times.
✓ Branch 2 taken 217533 times.
✓ Branch 3 taken 299 times.
13019260 if (isCuttableType(type) && MatchComboTrigger(w, combobuf, cid))
4454 {
4455 299 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4456 299 dontignore = 1;
4457 299 }
4458
4459 /*to-do, ffcs
4460 if (isCuttableType(type2) && MatchComboTrigger(w, combobuf, cid))
4461 {
4462 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4463 dontignoreffc = 1;
4464 }*/
4465
4/4
✓ Branch 0 taken 13018012 times.
✓ Branch 1 taken 1248 times.
✓ Branch 2 taken 13017713 times.
✓ Branch 3 taken 299 times.
13019260 if(w->useweapon != wSword && !dontignore) return;
4466
4467
4468 1547 int32_t i = (bx>>4) + by;
4469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
1547 if (get_bit(w->wscreengrid,(((bx>>4) + by))) ) return;
4470
4471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
1547 if(i > 175)
4472 return;
4473
4474 1547 bool ignorescreen=false;
4475 1547 bool ignoreffc=false;
4476
4477
1/2
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
1547 if(get_bit(w->wscreengrid, i) != 0)
4478 {
4479 ignorescreen = true; dontignore = 0;
4480 }
4481
4482 1547 int32_t current_ffcombo = getFFCAt(fx,fy);
4483
4484
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1545 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
1547 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4485 {
4486 1545 ignoreffc = true;
4487 1545 }
4488
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
4489 type2 = cNONE;
4490
3/4
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1248 times.
2795 if(!isCuttableType(type) &&
4491
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1248 times.
✓ Branch 2 taken 1248 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1248 times.
1248 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4492 {
4493 1248 ignorescreen = true;
4494 1248 }
4495
4496
2/4
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1547 times.
3094 if(!isCuttableType(type2) &&
4497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
1547 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4498 {
4499 1547 ignoreffc = true;
4500 1547 }
4501
4502 1547 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4503
4504
4/4
✓ Branch 0 taken 1254 times.
✓ Branch 1 taken 293 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 1248 times.
1547 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4505 1547 byte skipsecrets = 0;
4506
2/2
✓ Branch 0 taken 1298 times.
✓ Branch 1 taken 249 times.
1547 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
4507 {
4508
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (get_bit(quest_rules,qr_OLD_SLASHNEXT_SECRETS))
4509 {
4510 249 skipsecrets = 0;
4511 249 }
4512 else skipsecrets = 1;
4513 249 }
4514
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
✓ Branch 2 taken 1248 times.
✓ Branch 3 taken 1248 times.
✓ Branch 4 taken 1248 times.
✓ Branch 5 taken 1547 times.
1547 if((!skipsecrets || !get_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS)) && (!ignorescreen || dontignore))
4515 {
4516
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2795 if((flag >= 16)&&(flag <= 31)&&!skipsecrets)
4517 {
4518 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4519 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4520 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4521 }
4522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 else if(flag == mfARMOS_SECRET)
4523 {
4524 s->data[i] = s->secretcombo[sSTAIRS];
4525 s->cset[i] = s->secretcset[sSTAIRS];
4526 s->sflag[i] = s->secretflag[sSTAIRS];
4527 sfx(tmpscr->secretsfx);
4528 }
4529
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
299 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4530 {
4531 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4532 {
4533 findentrance(bx,by,mfSWORD+i2,true);
4534 }
4535
4536 findentrance(bx,by,mfSTRIKE,true);
4537 }
4538
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
299 else if(((flag2 >= 16)&&(flag2 <= 31)))
4539 {
4540 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4541 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4542 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4543 }
4544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 else if(flag2 == mfARMOS_SECRET)
4545 {
4546 s->data[i] = s->secretcombo[sSTAIRS];
4547 s->cset[i] = s->secretcset[sSTAIRS];
4548 s->sflag[i] = s->secretflag[sSTAIRS];
4549 sfx(tmpscr->secretsfx);
4550 }
4551
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
299 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4552 {
4553 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4554 {
4555 findentrance(bx,by,mfSWORD+i2,true);
4556 }
4557
4558 findentrance(bx,by,mfSTRIKE,true);
4559 }
4560 else
4561 {
4562
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 50 times.
299 if(isCuttableNextType(type))
4563 {
4564 249 s->data[i]++;
4565 249 }
4566 else
4567 {
4568 50 s->data[i] = s->undercombo;
4569 50 s->cset[i] = s->undercset;
4570 50 s->sflag[i] = 0;
4571 }
4572
4573 //pausenow=true;
4574 }
4575 299 }
4576
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1248 else if(skipsecrets && (!ignorescreen || dontignore))
4577 {
4578 if(isCuttableNextType(type))
4579 {
4580 s->data[i]++;
4581 }
4582 else
4583 {
4584 s->data[i] = s->undercombo;
4585 s->cset[i] = s->undercset;
4586 s->sflag[i] = 0;
4587 }
4588 }
4589
4590
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1547 times.
1547 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4591 {
4592 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4593 {
4594 findentrance(bx,by,mfSWORD+i2,true);
4595 }
4596
4597 findentrance(fx,fy,mfSTRIKE,true);
4598 }
4599
1/2
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
1547 else if(!ignoreffc)
4600 {
4601 if(isCuttableNextType(type2))
4602 {
4603 s->ffcs[current_ffcombo].incData(1);
4604 }
4605 else
4606 {
4607 s->ffcs[current_ffcombo].setData(s->undercombo);
4608 s->ffcs[current_ffcombo].cset = s->undercset;
4609 }
4610 }
4611
4612
3/4
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1248 times.
1547 if(!ignorescreen || dontignore)
4613 {
4614
3/4
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 88 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 211 times.
299 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid,i,1);
4615
4616
2/8
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
299 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4617 {
4618 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4619 sfx(tmpscr->secretsfx);
4620 }
4621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 else if(isCuttableItemType(type))
4622 {
4623 299 int32_t it = -1;
4624 299 int32_t thedropset = -1;
4625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
4626 {
4627 if ( combobuf[cid].usrflags&cflag11 )
4628 {
4629 it = combobuf[cid].attribytes[1];
4630 }
4631 else
4632 {
4633 it = select_dropitem(combobuf[cid].attribytes[1]);
4634 thedropset = combobuf[cid].attribytes[1];
4635 }
4636 }
4637 else
4638 {
4639 299 it = select_dropitem(12);
4640 299 thedropset = 12;
4641 }
4642
4643
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 99 times.
299 if(it!=-1)
4644 {
4645
4/8
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 99 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 99 times.
✗ Branch 7 not taken.
99 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4646 99 itm->from_dropset = thedropset;
4647 99 items.add(itm);
4648 99 }
4649 299 }
4650
4651
4652 299 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4653
4654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if(get_bit(quest_rules,qr_MORESOUNDS))
4655 {
4656
5/6
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 50 times.
✓ Branch 4 taken 161 times.
✗ Branch 5 not taken.
299 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4657 {
4658 if (combobuf[cid].usrflags&cflag3)
4659 {
4660 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4661 }
4662 }
4663 else
4664 {
4665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if (combobuf[cid].usrflags&cflag3)
4666 {
4667 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4668 }
4669 299 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4670 }
4671 299 }
4672
4673
2/4
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 299 times.
✗ Branch 3 not taken.
299 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4674
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 if(decotype > 3) decotype = 0;
4675
1/8
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
299 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4676
2/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✓ Branch 4 taken 50 times.
✗ Branch 5 not taken.
299 switch(decotype)
4677 {
4678 case -2: break; //nothing
4679 case -1:
4680 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4681 break;
4682
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
249 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4683
3/6
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50 times.
✗ Branch 5 not taken.
50 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4684 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4685 }
4686 299 }
4687
4688
1/2
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
1547 if(!ignoreffc)
4689 {
4690 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4691
4692 if(isCuttableItemType(type2))
4693 {
4694 int32_t it=-1;
4695 int32_t thedropset=-1;
4696 if ( (combobuf[cid].usrflags&cflag2) )
4697 {
4698 if(combobuf[cid].usrflags&cflag11)
4699 it = combobuf[cid].attribytes[1];
4700 else
4701 {
4702 it = select_dropitem(combobuf[cid].attribytes[1]);
4703 thedropset = combobuf[cid].attribytes[1];
4704 }
4705 }
4706 else
4707 {
4708 int32_t r=zc_oldrand()%100;
4709
4710 if(r<15)
4711 {
4712 it=iHeart; // 15%
4713 }
4714 else if(r<35)
4715 {
4716 it=iRupy; // 20%
4717 }
4718 }
4719
4720 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4721 {
4722 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4723 itm->from_dropset = thedropset;
4724 items.add(itm);
4725 }
4726 }
4727
4728 if(get_bit(quest_rules,qr_MORESOUNDS))
4729 {
4730 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4731 {
4732 if (combobuf[cid].usrflags&cflag3)
4733 {
4734 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4735 }
4736 }
4737 else
4738 {
4739 if (combobuf[cid].usrflags&cflag3)
4740 {
4741 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4742 }
4743 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4744 }
4745 }
4746
4747 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4748 if(decotype > 3) decotype = 0;
4749 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4750 switch(decotype)
4751 {
4752 case -2: break; //nothing
4753 case -1:
4754 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4755 break;
4756 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4757 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4758 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4759 }
4760 }
4761 13019260 }
4762
4763 13019260 void HeroClass::check_wand_block2(int32_t bx, int32_t by, weapon *w)
4764 {
4765 /*
4766 int32_t par_item = w->parentitem;
4767 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
4768 int32_t usewpn = -1;
4769 if ( par_item > -1 )
4770 {
4771 usewpn = itemsbuf[par_item].useweapon;
4772 }
4773 else if ( par_item == -1 && w->ScriptGenerated )
4774 {
4775 usewpn = w->useweapon;
4776 }
4777 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
4778 */
4779
4780 13019260 byte dontignore = 0;
4781 13019260 byte dontignoreffc = 0;
4782
4783
4784
4785
4786
4787 //keep things inside the screen boundaries
4788 13019260 bx=vbound(bx, 0, 255);
4789 13019260 by=vbound(by, 0, 176);
4790 13019260 int32_t fx=vbound(bx, 0, 255);
4791 13019260 int32_t fy=vbound(by, 0, 176);
4792 13019260 int32_t cid = MAPCOMBO(bx,by);
4793
4794 //Z_scripterrlog("check_wand_block2 MatchComboTrigger() returned: %d\n", );
4795
3/4
✓ Branch 0 taken 13019260 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659 times.
✓ Branch 3 taken 13018601 times.
13019260 if(w->useweapon != wWand && !MatchComboTrigger (w, combobuf, cid)) return;
4796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 659 times.
659 if ( MatchComboTrigger (w, combobuf, cid) ) dontignore = 1;
4797
4798 //first things first
4799
2/4
✓ Branch 0 taken 659 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 659 times.
659 if(z>8||fakez>8) return;
4800
4801 //find out which combo row/column the coordinates are in
4802 659 bx &= 0xF0;
4803 659 by &= 0xF0;
4804
4805 659 int32_t flag = MAPFLAG(bx,by);
4806 659 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4807 659 int32_t flag3=0;
4808 659 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
4809 659 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
4810 659 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
4811 659 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
4812
4813
4/8
✓ Branch 0 taken 659 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 659 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 659 times.
659 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
4814 flag3=mfWAND;
4815
4816
4/8
✓ Branch 0 taken 659 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 659 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 659 times.
659 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
4817 flag3=mfSTRIKE;
4818
4819 659 int32_t i = (bx>>4) + by;
4820
4821
6/12
✓ Branch 0 taken 659 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 659 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 659 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 659 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 659 times.
659 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
4822 659 return;
4823
4824 if(i > 175)
4825 return;
4826
4827 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4828
4829 //findentrance(bx,by,mfWAND,true);
4830 //findentrance(bx,by,mfSTRIKE,true);
4831 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
4832 {
4833 if(flag3==mfWAND||flag3==mfSTRIKE)
4834 {
4835 findentrance(fx,fy,mfWAND,true);
4836 findentrance(fx,fy,mfSTRIKE,true);
4837 }
4838 }
4839
4840 if(dontignore) { findentrance(bx,by,mfWAND,true); }
4841
4842 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4843 13019260 }
4844
4845 void HeroClass::check_slash_block(weapon *w)
4846 {
4847 //first things
4848
4849 int32_t par_item = w->parentitem;
4850 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4851 int32_t usewpn = -1;
4852 if ( par_item > -1 )
4853 {
4854 usewpn = itemsbuf[par_item].useweapon;
4855 }
4856 else if ( par_item == -1 && w->ScriptGenerated )
4857 {
4858 usewpn = w->useweapon;
4859 }
4860 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4861 if(usewpn != wSword) return;
4862
4863
4864 int32_t bx = 0, by = 0;
4865 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
4866 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
4867 al_trace("check_slash_block(weapon *w): bx is: %d\n", bx);
4868 al_trace("check_slash_block(weapon *w): by is: %d\n", by);
4869 //keep things inside the screen boundaries
4870 bx=vbound(bx, 0, 255);
4871 by=vbound(by, 0, 176);
4872 int32_t fx=vbound(bx, 0, 255);
4873 int32_t fy=vbound(by, 0, 176);
4874
4875 int32_t cid = MAPCOMBO(bx,by);
4876
4877 //find out which combo row/column the coordinates are in
4878 bx &= 0xF0;
4879 by &= 0xF0;
4880
4881 int32_t type = COMBOTYPE(bx,by);
4882 int32_t type2 = FFCOMBOTYPE(fx,fy);
4883 int32_t flag = MAPFLAG(bx,by);
4884 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4885 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4886 int32_t i = (bx>>4) + by;
4887
4888 if(i > 175)
4889 {
4890 al_trace("check_slash_block(weapon *w): %s\n", "i > 175");
4891 return;
4892 }
4893
4894 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4895 type = cNONE;
4896 bool ignorescreen=false;
4897 bool ignoreffc=false;
4898
4899 if(get_bit(screengrid, i) != 0)
4900 {
4901 ignorescreen = true;
4902 }
4903
4904 int32_t current_ffcombo = getFFCAt(fx,fy);
4905
4906 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4907 {
4908 ignoreffc = true;
4909 }
4910 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
4911 type2 = cNONE;
4912 if(!isCuttableType(type) &&
4913 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4914 {
4915 ignorescreen = true;
4916 }
4917
4918 if(!isCuttableType(type2) &&
4919 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4920 {
4921 ignoreffc = true;
4922 }
4923
4924 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4925
4926 int32_t sworditem = (par_item >-1 ? itemsbuf[par_item].fam_type : current_item(itype_sword)); //Get the level of the item, else the highest sword level in inventory.
4927
4928 if(!ignorescreen)
4929 {
4930 if((flag >= 16)&&(flag <= 31))
4931 {
4932 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4933 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4934 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4935 }
4936 else if(flag == mfARMOS_SECRET)
4937 {
4938 s->data[i] = s->secretcombo[sSTAIRS];
4939 s->cset[i] = s->secretcset[sSTAIRS];
4940 s->sflag[i] = s->secretflag[sSTAIRS];
4941 sfx(tmpscr->secretsfx);
4942 }
4943 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4944 {
4945 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4946 {
4947 findentrance(bx,by,mfSWORD+i2,true);
4948 }
4949
4950 findentrance(bx,by,mfSTRIKE,true);
4951 }
4952 else if(((flag2 >= 16)&&(flag2 <= 31)))
4953 {
4954 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4955 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4956 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4957 }
4958 else if(flag2 == mfARMOS_SECRET)
4959 {
4960 s->data[i] = s->secretcombo[sSTAIRS];
4961 s->cset[i] = s->secretcset[sSTAIRS];
4962 s->sflag[i] = s->secretflag[sSTAIRS];
4963 sfx(tmpscr->secretsfx);
4964 }
4965 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4966 {
4967 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4968 {
4969 findentrance(bx,by,mfSWORD+i2,true);
4970 }
4971
4972 findentrance(bx,by,mfSTRIKE,true);
4973 }
4974 else
4975 {
4976 if(isCuttableNextType(type))
4977 {
4978 s->data[i]++;
4979 }
4980 else
4981 {
4982 s->data[i] = s->undercombo;
4983 s->cset[i] = s->undercset;
4984 s->sflag[i] = 0;
4985 }
4986
4987 //pausenow=true;
4988 }
4989 }
4990
4991 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4992 {
4993 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4994 {
4995 findentrance(bx,by,mfSWORD+i2,true);
4996 }
4997
4998 findentrance(fx,fy,mfSTRIKE,true);
4999 }
5000 else if(!ignoreffc)
5001 {
5002 if(isCuttableNextType(type2))
5003 {
5004 s->ffcs[current_ffcombo].incData(1);
5005 }
5006 else
5007 {
5008 s->ffcs[current_ffcombo].setData(s->undercombo);
5009 s->ffcs[current_ffcombo].cset = s->undercset;
5010 }
5011 }
5012
5013 if(!ignorescreen)
5014 {
5015 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
5016
5017 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5018 {
5019 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5020 sfx(tmpscr->secretsfx);
5021 }
5022 else if(isCuttableItemType(type))
5023 {
5024 int32_t it = -1;
5025 int32_t thedropset = -1;
5026 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
5027 {
5028 if ( combobuf[cid].usrflags&cflag11 )
5029 {
5030 it = combobuf[cid].attribytes[1];
5031 }
5032 else
5033 {
5034 it = select_dropitem(combobuf[cid].attribytes[1]);
5035 thedropset = combobuf[cid].attribytes[1];
5036 }
5037 }
5038 else
5039 {
5040 it = select_dropitem(12);
5041 thedropset = 12;
5042 }
5043
5044 if(it!=-1)
5045 {
5046 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5047 itm->from_dropset = thedropset;
5048 items.add(itm);
5049 }
5050 }
5051
5052 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5053
5054 if(get_bit(quest_rules,qr_MORESOUNDS))
5055 {
5056 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
5057 {
5058 if (combobuf[cid].usrflags&cflag3)
5059 {
5060 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5061 }
5062 }
5063 else
5064 {
5065 if (combobuf[cid].usrflags&cflag3)
5066 {
5067 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5068 }
5069 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5070 }
5071 }
5072
5073 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5074 if(decotype > 3) decotype = 0;
5075 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5076 switch(decotype)
5077 {
5078 case -2: break; //nothing
5079 case -1:
5080 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
5081 break;
5082 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5083 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5084 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5085 }
5086 }
5087
5088 if(!ignoreffc)
5089 {
5090 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
5091
5092 if(isCuttableItemType(type2))
5093 {
5094 int32_t it=-1;
5095 int32_t thedropset = -1;
5096 if ( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) )
5097 {
5098 if(combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag11)
5099 it = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5100 else
5101 {
5102 thedropset = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5103 it = select_dropitem(thedropset);
5104 }
5105 }
5106 else
5107 {
5108 it = select_dropitem(12);
5109 thedropset = 12;
5110 }
5111
5112 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
5113 {
5114 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5115 itm->from_dropset = thedropset;
5116 items.add(itm);
5117 }
5118 }
5119
5120 if(get_bit(quest_rules,qr_MORESOUNDS))
5121 {
5122 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
5123 {
5124 if (combobuf[cid].usrflags&cflag3)
5125 {
5126 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5127 }
5128 }
5129 else
5130 {
5131 if (combobuf[cid].usrflags&cflag3)
5132 {
5133 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5134 }
5135 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5136 }
5137 }
5138
5139 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5140 if(decotype > 3) decotype = 0;
5141 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5142 switch(decotype)
5143 {
5144 case -2: break; //nothing
5145 case -1:
5146 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
5147 break;
5148 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5149 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5150 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5151 }
5152 }
5153 }
5154
5155 //TODO: Boomerang that cuts bushes. -L
5156 /*void HeroClass::slash_bush()
5157 {
5158
5159 }*/
5160
5161 31820 void HeroClass::check_wand_block(int32_t bx, int32_t by)
5162 {
5163 //keep things inside the screen boundaries
5164 31820 bx=vbound(bx, 0, 255);
5165 31820 by=vbound(by, 0, 176);
5166 31820 int32_t fx=vbound(bx, 0, 255);
5167 31820 int32_t fy=vbound(by, 0, 176);
5168 31820 int32_t cid = MAPCOMBO(bx,by);
5169
5170 //first things first
5171
2/4
✓ Branch 0 taken 31820 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31820 times.
31820 if(z>8||fakez>8) return;
5172
5173 //find out which combo row/column the coordinates are in
5174 31820 bx &= 0xF0;
5175 31820 by &= 0xF0;
5176
5177 31820 int32_t flag = MAPFLAG(bx,by);
5178 31820 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5179 31820 int32_t flag3=0;
5180 31820 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5181 31820 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5182 31820 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5183 31820 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5184
5185
4/8
✓ Branch 0 taken 31820 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31820 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31820 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 31820 times.
31820 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5186 flag3=mfWAND;
5187
5188
4/8
✓ Branch 0 taken 31820 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31820 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31820 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 31820 times.
31820 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5189 flag3=mfSTRIKE;
5190
5191 31820 int32_t i = (bx>>4) + by;
5192
5193
6/12
✓ Branch 0 taken 31820 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31820 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31820 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 31820 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 31820 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 31820 times.
✗ Branch 11 not taken.
31820 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5194 31820 return;
5195
5196 if(i > 175)
5197 return;
5198
5199 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5200
5201 //findentrance(bx,by,mfWAND,true);
5202 //findentrance(bx,by,mfSTRIKE,true);
5203 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5204 {
5205 if(flag3==mfWAND||flag3==mfSTRIKE)
5206 {
5207 findentrance(fx,fy,mfWAND,true);
5208 findentrance(fx,fy,mfSTRIKE,true);
5209 }
5210 }
5211
5212 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5213 31820 }
5214
5215 1704 void HeroClass::check_pound_block(int bx, int by, weapon* w)
5216 {
5217
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1704 if(w && w->no_triggers()) return;
5218
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1704 if(w && w->id == wHammer && getHammerState() < 3)
5219 return;
5220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1704 times.
1704 if(get_bit(quest_rules,qr_POUNDLAYERS1AND2))
5221 {
5222 check_pound_block_layer(bx,by,1,w);
5223 check_pound_block_layer(bx,by,2,w);
5224 }
5225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1704 times.
1704 auto* grid = w ? w->wscreengrid : screengrid;
5226 //keep things inside the screen boundaries
5227 1704 bx=vbound(bx, 0, 255);
5228 1704 by=vbound(by, 0, 176);
5229 1704 int32_t fx=vbound(bx, 0, 255);
5230 1704 int32_t fy=vbound(by, 0, 176);
5231 1704 int32_t cid = MAPCOMBO(bx,by);
5232
5233 //first things first
5234
2/4
✓ Branch 0 taken 1704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1704 times.
1704 if(z>8||fakez>8) return;
5235
5236 //find out which combo row/column the coordinates are in
5237 1704 bx &= 0xF0;
5238 1704 by &= 0xF0;
5239
5240 1704 int32_t type = COMBOTYPE(bx,by);
5241 1704 int32_t type2 = FFCOMBOTYPE(fx,fy);
5242 1704 int32_t flag = MAPFLAG(bx,by);
5243 1704 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5244 1704 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5245 1704 int32_t i = (bx>>4) + by;
5246
5247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1704 times.
1704 if(i > 175)
5248 return;
5249
5250 1704 bool ignorescreen=false;
5251 1704 bool ignoreffc=false;
5252 1704 bool pound=false;
5253
5254
6/10
✓ Branch 0 taken 1646 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 1646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1646 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1646 times.
1704 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5255 1646 ignorescreen = true; // Affect only FFCs
5256
5257
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 27 times.
1704 if(get_bit(grid, i) != 0)
5258 27 ignorescreen = true;
5259
5260 1704 int32_t current_ffcombo = getFFCAt(fx,fy);
5261
5262
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1703 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1704 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5263 1703 ignoreffc = true;
5264
5265
3/6
✓ Branch 0 taken 1704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1704 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1704 times.
1704 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
5266 1704 ignoreffc = true;
5267
5268
3/4
✓ Branch 0 taken 1654 times.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1654 times.
1704 if(ignorescreen && ignoreffc) // Nothing to do.
5269 1654 return;
5270
5271 50 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5272
5273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if(!ignorescreen)
5274 {
5275
2/4
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50 times.
50 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5276 {
5277 findentrance(bx,by,mfHAMMER,true);
5278 findentrance(bx,by,mfSTRIKE,true);
5279 }
5280
2/4
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50 times.
50 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5281 {
5282 findentrance(bx,by,mfHAMMER,true);
5283 findentrance(bx,by,mfSTRIKE,true);
5284 }
5285
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 else if((flag >= 16)&&(flag <= 31))
5286 {
5287 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5288 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5289 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5290 }
5291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 else if(flag == mfARMOS_SECRET)
5292 {
5293 s->data[i] = s->secretcombo[sSTAIRS];
5294 s->cset[i] = s->secretcset[sSTAIRS];
5295 s->sflag[i] = s->secretflag[sSTAIRS];
5296 sfx(tmpscr->secretsfx);
5297 }
5298
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 else if((flag2 >= 16)&&(flag2 <= 31))
5299 {
5300 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5301 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5302 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5303 }
5304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 else if(flag2 == mfARMOS_SECRET)
5305 {
5306 s->data[i] = s->secretcombo[sSTAIRS];
5307 s->cset[i] = s->secretcset[sSTAIRS];
5308 s->sflag[i] = s->secretflag[sSTAIRS];
5309 sfx(tmpscr->secretsfx);
5310 }
5311 50 else pound = true;
5312 50 }
5313
5314
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if(!ignoreffc)
5315 {
5316 if(flag3==mfHAMMER||flag3==mfSTRIKE)
5317 {
5318 findentrance(fx,fy,mfHAMMER,true);
5319 findentrance(fx,fy,mfSTRIKE,true);
5320 }
5321 else
5322 {
5323 s->ffcs[current_ffcombo].incData(1);
5324 }
5325 }
5326
5327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if(!ignorescreen)
5328 {
5329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if(pound)
5330 50 s->data[i]+=1;
5331
5332 50 set_bit(grid,i,1);
5333
5334
2/8
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
50 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5335 {
5336 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5337 sfx(tmpscr->secretsfx);
5338 }
5339
5340
2/4
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
50 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5341 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5342
5343 50 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5344 50 }
5345
5346
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if(!ignoreffc)
5347 {
5348 set_bit(ffcgrid,current_ffcombo,1);
5349
5350 if(type2==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5351 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5352 }
5353
5354 50 return;
5355 1704 }
5356
5357 void HeroClass::check_pound_block_layer(int bx, int by, int lyr, weapon* w)
5358 {
5359 if(lyr < 1 || lyr > 2) return; //sanity
5360 //keep things inside the screen boundaries
5361 bx=vbound(bx, 0, 255);
5362 by=vbound(by, 0, 176);
5363 int32_t cid = MAPCOMBOL(lyr,bx,by);
5364 newcombo const& scr_cmb = combobuf[cid];
5365 auto* grid = w ? w->wscreengrid_layer[lyr-1] : screengrid_layer[lyr-1];
5366
5367 //first things first
5368 if(z>8||fakez>8) return;
5369
5370 //find out which combo row/column the coordinates are in
5371 bx &= 0xF0;
5372 by &= 0xF0;
5373
5374 int32_t type = scr_cmb.type;
5375 int32_t flag = MAPFLAGL(lyr,bx,by);
5376 int32_t flag2 = scr_cmb.flag;
5377 int32_t i = (bx>>4) + by;
5378
5379 if(i > 175)
5380 return;
5381
5382 bool pound=false;
5383
5384 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5385 return;
5386
5387 if(get_bit(grid, i) != 0)
5388 return;
5389
5390 mapscr *s = FFCore.tempScreens[lyr];
5391
5392 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5393 {
5394 findentrance(bx,by,mfHAMMER,true);
5395 findentrance(bx,by,mfSTRIKE,true);
5396 }
5397 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5398 {
5399 findentrance(bx,by,mfHAMMER,true);
5400 findentrance(bx,by,mfSTRIKE,true);
5401 }
5402 else if((flag >= 16)&&(flag <= 31))
5403 {
5404 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5405 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5406 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5407 }
5408 else if(flag == mfARMOS_SECRET)
5409 {
5410 s->data[i] = s->secretcombo[sSTAIRS];
5411 s->cset[i] = s->secretcset[sSTAIRS];
5412 s->sflag[i] = s->secretflag[sSTAIRS];
5413 sfx(tmpscr->secretsfx);
5414 }
5415 else if((flag2 >= 16)&&(flag2 <= 31))
5416 {
5417 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5418 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5419 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5420 }
5421 else if(flag2 == mfARMOS_SECRET)
5422 {
5423 s->data[i] = s->secretcombo[sSTAIRS];
5424 s->cset[i] = s->secretcset[sSTAIRS];
5425 s->sflag[i] = s->secretflag[sSTAIRS];
5426 sfx(tmpscr->secretsfx);
5427 }
5428 else pound = true;
5429
5430 if(pound)
5431 s->data[i]+=1;
5432
5433 set_bit(grid,i,1);
5434
5435 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5436 {
5437 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5438 sfx(tmpscr->secretsfx);
5439 }
5440
5441 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5442 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5443
5444 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5445 }
5446
5447 void HeroClass::check_wand_block(weapon *w)
5448 {
5449
5450 int32_t par_item = w->parentitem;
5451 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
5452 int32_t usewpn = -1;
5453 if ( par_item > -1 )
5454 {
5455 usewpn = itemsbuf[par_item].useweapon;
5456 }
5457 else if ( par_item == -1 && w->ScriptGenerated )
5458 {
5459 usewpn = w->useweapon;
5460 }
5461 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
5462 if(usewpn != wWand) return;
5463
5464
5465 int32_t bx = 0, by = 0;
5466 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
5467 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
5468
5469 //keep things inside the screen boundaries
5470 bx=vbound(bx, 0, 255);
5471 by=vbound(by, 0, 176);
5472 int32_t fx=vbound(bx, 0, 255);
5473 int32_t fy=vbound(by, 0, 176);
5474 int32_t cid = MAPCOMBO(bx,by);
5475 //first things first
5476 if(z>8||fakez>8) return;
5477
5478 //find out which combo row/column the coordinates are in
5479 bx &= 0xF0;
5480 by &= 0xF0;
5481
5482 int32_t flag = MAPFLAG(bx,by);
5483 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5484 int32_t flag3=0;
5485 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5486 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5487 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5488 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5489
5490 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5491 flag3=mfWAND;
5492
5493 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5494 flag3=mfSTRIKE;
5495
5496 int32_t i = (bx>>4) + by;
5497
5498 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5499 return;
5500
5501 if(i > 175)
5502 return;
5503
5504 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5505
5506 //findentrance(bx,by,mfWAND,true);
5507 //findentrance(bx,by,mfSTRIKE,true);
5508 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5509 {
5510 if(flag3==mfWAND||flag3==mfSTRIKE)
5511 {
5512 findentrance(fx,fy,mfWAND,true);
5513 findentrance(fx,fy,mfSTRIKE,true);
5514 }
5515 }
5516
5517 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5518 }
5519
5520 //defend results should match defence types.
5521 //RETURN VALUES:
5522 // -1 iGNORE WEAPON
5523 // 0 No effects
5524 // 1 Effects, weapon is not ignored or removed
5525 6603 int32_t HeroClass::defend(weapon *w)
5526 {
5527 6603 int32_t def = conv_edef_unblockable(defence[w->id], w->unblockable);
5528
1/25
✓ Branch 0 taken 6603 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
6603 switch(def)
5529 {
5530 6603 case edNORMAL: return 1;
5531 case edHALFDAMAGE: // : IMPLEMENTED : Take half damage
5532 {
5533 w->power *= 0.5;
5534 return 1;
5535 }
5536 case edQUARTDAMAGE:
5537 {
5538 w->power *= 0.25;
5539 return 1;
5540 }
5541 case edSTUNONLY:
5542 {
5543 setStunClock(120);
5544 return 1;
5545 }
5546 case edSTUNORCHINK: // : IMPLEMENTED : If damage > 0, stun instead. Else, bounce off.
5547 {
5548 if (w->power > 0)
5549 {
5550 setStunClock(120);
5551 return 1;
5552 }
5553 else
5554 {
5555 sfx(WAV_CHINK,pan(int32_t(x)));
5556 w->dead = 0;
5557 return -1;
5558 }
5559 }
5560 case edSTUNORIGNORE: // : IMPLEMENTED : If damage > 0, stun instead. Else, ignore.
5561 {
5562 if (w->power > 0)
5563 {
5564 setStunClock(120);
5565 return 1;
5566 }
5567 else
5568 {
5569 return -1;
5570 }
5571 }
5572 case edCHINKL1: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5573 {
5574 if (w->power < 1)
5575 {
5576 sfx(WAV_CHINK,pan(int32_t(x)));
5577 w->dead = 0;
5578 return -1;
5579 }
5580 else
5581 {
5582 return 1;
5583 }
5584 }
5585 case edCHINKL2: // : IMPLEMENTED : Bounce off unless damage >= 2
5586 {
5587 if (w->power < 2)
5588 {
5589 sfx(WAV_CHINK,pan(int32_t(x)));
5590 w->dead = 0;
5591 return -1;
5592 }
5593 else
5594 {
5595 return 1;
5596 }
5597 }
5598 case edCHINKL4: //: IMPLEMENTED : Bounce off unless damage >= 4
5599 {
5600 if (w->power < 4)
5601 {
5602 sfx(WAV_CHINK,pan(int32_t(x)));
5603 w->dead = 0;
5604 return -1;
5605 }
5606 else
5607 {
5608 return 1;
5609 }
5610 }
5611 case edCHINKL6: // : IMPLEMENTED : Bounce off unless damage >= 6
5612 {
5613 if (w->power < 6)
5614 {
5615 sfx(WAV_CHINK,pan(int32_t(x)));
5616 w->dead = 0;
5617 return -1;
5618 }
5619 else
5620 {
5621 return 1;
5622 }
5623 }
5624 case edCHINKL8: // : IMPLEMENTED : Bounce off unless damage >= 8
5625 {
5626 if (w->power < 8)
5627 {
5628 sfx(WAV_CHINK,pan(int32_t(x)));
5629 w->dead = 0;
5630 return -1;
5631 }
5632 else
5633 {
5634 return 1;
5635 }
5636 }
5637 case edCHINK: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5638 {
5639 sfx(WAV_CHINK,pan(int32_t(x)));
5640 w->dead = 0;
5641 return -1;
5642 }
5643 case edIGNOREL1: // : IMPLEMENTED : Ignore unless damage > 1.
5644 {
5645 if (w->power < 1)
5646 {
5647 return -1;
5648 }
5649 else return 1;
5650 }
5651 case edIGNORE: // : IMPLEMENTED : Do Nothing
5652 {
5653 return -1;
5654 }
5655 case ed1HKO: // : IMPLEMENTED : One-hit knock-out
5656 {
5657 game->set_life(0);
5658 return 1;
5659 }
5660 case edCHINKL10: //: IMPLEMENTED : If damage is less than 10
5661 {
5662 if (w->power < 10)
5663 {
5664 sfx(WAV_CHINK,pan(int32_t(x)));
5665 w->dead = 0;
5666 return -1;
5667 }
5668 else
5669 {
5670 return 1;
5671 }
5672 }
5673 case ed2x: // : IMPLEMENTED : Double damage.
5674 {
5675 w->power *= 2;
5676 return 1;
5677 }
5678 case ed3x: // : IMPLEMENTED : Triple Damage.
5679 {
5680 w->power *= 3;
5681 return 1;
5682 }
5683 case ed4x: // : IMPLEMENTED : 4x damage.
5684 {
5685 w->power *= 4;
5686 return 1;
5687 }
5688 case edHEAL: // : IMPLEMENTED : Gain the weapon damage in HP.
5689 {
5690 //sfx(WAV_HEAL,pan(int32_t(x)));
5691 game->set_life(zc_min(game->get_life()+w->power, game->get_maxlife()));
5692 w->dead = 0;
5693 return -1;
5694 }
5695
5696 case edFREEZE: return 1; //Not IMPLEMENTED
5697
5698 case edLEVELDAMAGE: //Damage * item level
5699 {
5700 w->power *= w->family_level;
5701 return 1;
5702 }
5703 case edLEVELREDUCTION: //Damage / item level
5704 {
5705 if ( w->family_level > 0 )
5706 {
5707 w->power /= w->family_level;
5708 }
5709 else w->power = 0;
5710 return 1;
5711 }
5712
5713 //edLEVELCHINK2, //If item level is < 2: This needs a weapon variable that is set by
5714 //edLEVELCHINK3, //If item level is < 3: the item that generates it (itemdata::level stored to
5715 //edLEVELCHINK4, //If item level is < 4: weapon::level, or something similar; then a check to
5716 //edLEVELCHINK5, //If item level is < 5: read weapon::level in hit detection.
5717
5718 //edSHOCK, //buzz blob
5719
5720
5721 case edBREAKSHIELD: //destroy the player's present shield
5722 {
5723 w->power = 0;
5724 w->dead = 0;
5725 int32_t itemid = getCurrentShield();
5726 //sfx(WAV_BREAKSHIELD,pan(int32_t(x)));
5727 if(itemsbuf[itemid].flags&ITEM_EDIBLE)
5728 game->set_item(itemid, false);
5729 //Remove Hero's shield
5730 return -1;
5731 }
5732
5733
5734
5735 default: return 0;
5736 }
5737 6603 }
5738 ALLEGRO_COLOR HeroClass::hitboxColor(byte opacity) const
5739 {
5740 return al_map_rgba(0,0,255,opacity);
5741 }
5742 6401 int32_t HeroClass::compareDir(int32_t other)
5743 {
5744
5/6
✓ Branch 0 taken 6396 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6396 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 6399 times.
6401 if(other != NORMAL_DIR(other))
5745 2 return 0; //*sigh* scripts expect dirs >=8 to NOT hit shields...
5746 6399 int32_t ret = 0;
5747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6399 times.
6399 auto d = (shield_forcedir < 0) ? dir : shield_forcedir;
5748
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1368 times.
✓ Branch 2 taken 1045 times.
✓ Branch 3 taken 2004 times.
✓ Branch 4 taken 1982 times.
6399 switch(d)
5749 {
5750 case up:
5751 {
5752
3/3
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 526 times.
✓ Branch 2 taken 519 times.
1368 switch(X_DIR(other))
5753 {
5754 case left:
5755 526 ret |= CMPDIR_RIGHT;
5756 526 break;
5757 case right:
5758 519 ret |= CMPDIR_LEFT;
5759 519 break;
5760 }
5761
3/3
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 229 times.
✓ Branch 2 taken 980 times.
1368 switch(Y_DIR(other))
5762 {
5763 case up:
5764 229 ret |= CMPDIR_BACK;
5765 229 break;
5766 case down:
5767 980 ret |= CMPDIR_FRONT;
5768 980 break;
5769 }
5770 1368 break;
5771 }
5772 case down:
5773 {
5774
3/3
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 330 times.
✓ Branch 2 taken 405 times.
1045 switch(X_DIR(other))
5775 {
5776 case left:
5777 330 ret |= CMPDIR_LEFT;
5778 330 break;
5779 case right:
5780 405 ret |= CMPDIR_RIGHT;
5781 405 break;
5782 }
5783
3/3
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 731 times.
✓ Branch 2 taken 180 times.
1045 switch(Y_DIR(other))
5784 {
5785 case up:
5786 731 ret |= CMPDIR_FRONT;
5787 731 break;
5788 case down:
5789 180 ret |= CMPDIR_BACK;
5790 180 break;
5791 }
5792 1045 break;
5793 }
5794 case left:
5795 {
5796
3/3
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 293 times.
✓ Branch 2 taken 1620 times.
2004 switch(X_DIR(other))
5797 {
5798 case left:
5799 293 ret |= CMPDIR_BACK;
5800 293 break;
5801 case right:
5802 1620 ret |= CMPDIR_FRONT;
5803 1620 break;
5804 }
5805
3/3
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 613 times.
✓ Branch 2 taken 674 times.
2004 switch(Y_DIR(other))
5806 {
5807 case up:
5808 613 ret |= CMPDIR_LEFT;
5809 613 break;
5810 case down:
5811 674 ret |= CMPDIR_RIGHT;
5812 674 break;
5813 }
5814 2004 break;
5815 }
5816 case right:
5817 {
5818
3/3
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 1630 times.
✓ Branch 2 taken 259 times.
1982 switch(X_DIR(other))
5819 {
5820 case left:
5821 1630 ret |= CMPDIR_FRONT;
5822 1630 break;
5823 case right:
5824 259 ret |= CMPDIR_BACK;
5825 259 break;
5826 }
5827
3/3
✓ Branch 0 taken 757 times.
✓ Branch 1 taken 510 times.
✓ Branch 2 taken 715 times.
1982 switch(Y_DIR(other))
5828 {
5829 case up:
5830 510 ret |= CMPDIR_RIGHT;
5831 510 break;
5832 case down:
5833 715 ret |= CMPDIR_LEFT;
5834 715 break;
5835 }
5836 1982 break;
5837 }
5838 }
5839 6399 return ret;
5840 6401 }
5841
5842 6401 bool compareShield(int32_t cmpdir, itemdata const& shield)
5843 {
5844
1/2
✓ Branch 0 taken 6401 times.
✗ Branch 1 not taken.
6401 bool standard = !(shield.flags&ITEM_FLAG9) || usingActiveShield();
5845
1/2
✓ Branch 0 taken 6401 times.
✗ Branch 1 not taken.
6401 if(standard) //Use standard sides, either a passive shield, or a held active shield
5846 {
5847
3/4
✓ Branch 0 taken 4961 times.
✓ Branch 1 taken 1440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4961 times.
6401 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG1))
5848 4961 return true;
5849
3/4
✓ Branch 0 taken 961 times.
✓ Branch 1 taken 479 times.
✓ Branch 2 taken 961 times.
✗ Branch 3 not taken.
1440 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG2))
5850 return true;
5851
3/4
✓ Branch 0 taken 607 times.
✓ Branch 1 taken 833 times.
✓ Branch 2 taken 607 times.
✗ Branch 3 not taken.
1440 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG3))
5852 return true;
5853
3/4
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 645 times.
1440 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG4))
5854 return true;
5855 1440 }
5856 else //Active Shield that is NOT held down
5857 {
5858 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG5))
5859 return true;
5860 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG6))
5861 return true;
5862 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG7))
5863 return true;
5864 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG8))
5865 return true;
5866 }
5867 1440 return false;
5868 6401 }
5869
5870 5752087 int32_t HeroClass::EwpnHit()
5871 {
5872
2/2
✓ Branch 0 taken 5749196 times.
✓ Branch 1 taken 4053865 times.
9803061 for(int32_t i=0; i<Ewpns.Count(); i++)
5873 {
5874
2/2
✓ Branch 0 taken 4047262 times.
✓ Branch 1 taken 6603 times.
4053865 if(Ewpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
5875 {
5876 6603 weapon *ew = (weapon*)(Ewpns.spr(i));
5877
5878
3/6
✓ Branch 0 taken 6603 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6603 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6603 times.
6603 if((ew->ignoreHero)==true || ew->fallclk|| ew->drownclk)
5879 break;
5880
5881 6603 int32_t stompid = current_item_id(itype_stompboots);
5882
5883
5/10
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6597 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
6603 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
5884
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((z+fakez) > (ew->z+(ew->fakez))) ||
5885
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 ((isSideViewHero() && (y+16)-(ew->y)<=14) && falling_oldy<y)))
5886 {
5887 itemdata const& stomp = itemsbuf[stompid];
5888 bool remove = false;
5889 switch(ew->id)
5890 {
5891 case ewFireball2:
5892 case ewFireball:
5893 if(ew->type & 1) //Boss fireball
5894 {
5895 if(stomp.misc2 & (shFIREBALL2))
5896 remove = true;
5897 }
5898 else
5899 {
5900 if(stomp.misc2 & (shFIREBALL))
5901 remove = true;
5902 }
5903
5904 break;
5905
5906 case ewMagic:
5907 if((stomp.misc2 & shMAGIC))
5908 remove = true;
5909 break;
5910
5911 case ewSword:
5912 if((stomp.misc2 & shSWORD))
5913 remove = true;
5914
5915 break;
5916
5917 case ewFlame:
5918 if((stomp.misc2 & shFLAME))
5919 remove = true;
5920
5921 break;
5922
5923 case ewRock:
5924 if((stomp.misc2 & shROCK))
5925 remove = true;
5926
5927 break;
5928
5929 case ewArrow:
5930 if((stomp.misc2 & shARROW))
5931 remove = true;
5932
5933 break;
5934
5935 case ewBrang:
5936 if((stomp.misc2 & shBRANG))
5937 remove = true;
5938
5939 break;
5940
5941 default: // Just throw the script weapons in here...
5942 if(ew->id>=wScript1 && ew->id<=wScript10)
5943 {
5944 if((stomp.misc2 & shSCRIPT))
5945 remove = true;
5946 }
5947
5948 break;
5949 }
5950 if (remove)
5951 {
5952 ew->onhit(false);
5953 sfx(WAV_CHINK,pan(x.getInt()));
5954 continue;
5955 }
5956 }
5957
5958 6603 int32_t defresult = defend(ew);
5959
1/2
✓ Branch 0 taken 6603 times.
✗ Branch 1 not taken.
6603 if ( defresult == -1 ) return -1; //The weapon did something special, but it is otherwise ignored, possibly killed by defend().
5960
5961
2/2
✓ Branch 0 taken 6602 times.
✓ Branch 1 taken 1 times.
6603 if(ew->id==ewWind)
5962 {
5963 1 xofs=1000;
5964 1 action=freeze; FFCore.setHeroAction(freeze);
5965 1 ew->misc=999; // in enemy wind
5966 1 attackclk=0;
5967 1 return -1;
5968 }
5969
5970
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 6591 times.
6602 switch(ew->id)
5971 {
5972 case ewLitBomb:
5973 case ewBomb:
5974 case ewLitSBomb:
5975 case ewSBomb:
5976 11 return i;
5977 }
5978
5979 6591 int32_t itemid = getCurrentShield(false);
5980
4/6
✓ Branch 0 taken 6399 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 6399 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6399 times.
6591 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
5981 192 return i;
5982 6399 itemdata const& shield = itemsbuf[itemid];
5983 6399 bool allow_inactive = (shield.flags & ITEM_FLAG9);
5984 6399 auto cmpdir = compareDir(ew->dir);
5985 6399 bool hitshield = compareShield(cmpdir, shield);
5986
5987
12/20
✓ Branch 0 taken 6399 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6399 times.
✓ Branch 4 taken 5133 times.
✓ Branch 5 taken 1266 times.
✓ Branch 6 taken 5133 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5105 times.
✓ Branch 9 taken 28 times.
✓ Branch 10 taken 5105 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 5105 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 5105 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 5105 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 5105 times.
✗ Branch 19 not taken.
6399 if(!allow_inactive && ((lift_wpn && (liftflags & LIFTFL_DIS_SHIELD)) || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF))
5988 1294 return i;
5989
5990
2/2
✓ Branch 0 taken 4061 times.
✓ Branch 1 taken 1044 times.
5105 if(!hitshield)
5991 1044 return i;
5992
5993 4061 paymagiccost(itemid);
5994
5995 4061 bool reflect = false;
5996
5997
7/8
✓ Branch 0 taken 2227 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 545 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 349 times.
✓ Branch 5 taken 232 times.
✓ Branch 6 taken 227 times.
✓ Branch 7 taken 211 times.
4061 switch(ew->id)
5998 {
5999 case ewFireball2:
6000 case ewFireball:
6001
2/2
✓ Branch 0 taken 151 times.
✓ Branch 1 taken 2076 times.
2227 if(ew->type & 1) //Boss fireball
6002 {
6003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if(!(shield.misc1 & (shFIREBALL2)))
6004 151 return i;
6005
6006 reflect = ((shield.misc2 & shFIREBALL2) != 0);
6007 }
6008 else
6009 {
6010
2/2
✓ Branch 0 taken 1978 times.
✓ Branch 1 taken 98 times.
2076 if(!(shield.misc1 & (shFIREBALL)))
6011 98 return i;
6012
6013 1978 reflect = ((shield.misc2 & shFIREBALL) != 0);
6014 }
6015
6016 1978 break;
6017
6018 case ewMagic:
6019
2/2
✓ Branch 0 taken 517 times.
✓ Branch 1 taken 28 times.
545 if(!(shield.misc1 & shMAGIC))
6020 28 return i;
6021
6022 517 reflect = ((shield.misc2 & shMAGIC) != 0);
6023 517 break;
6024
6025 case ewSword:
6026
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 26 times.
270 if(!(shield.misc1 & shSWORD))
6027 26 return i;
6028
6029 244 reflect = ((shield.misc2 & shSWORD) != 0);
6030 244 break;
6031
6032 case ewFlame:
6033
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 46 times.
349 if(!(shield.misc1 & shFLAME))
6034 46 return i;
6035
6036 303 reflect = ((shield.misc2 & shFLAME) != 0); // Actually isn't reflected.
6037 303 break;
6038
6039 case ewRock:
6040
1/2
✓ Branch 0 taken 232 times.
✗ Branch 1 not taken.
232 if(!(shield.misc1 & shROCK))
6041 return i;
6042
6043 232 reflect = (shield.misc2 & shROCK);
6044 232 break;
6045
6046 case ewArrow:
6047
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 if(!(shield.misc1 & shARROW))
6048 return i;
6049
6050 227 reflect = ((shield.misc2 & shARROW) != 0); // Actually isn't reflected.
6051 227 break;
6052
6053 case ewBrang:
6054
1/2
✓ Branch 0 taken 211 times.
✗ Branch 1 not taken.
211 if(!(shield.misc1 & shBRANG))
6055 return i;
6056
6057 211 break;
6058
6059 default: // Just throw the script weapons in here...
6060 if(ew->id>=wScript1 && ew->id<=wScript10)
6061 {
6062 if(!(shield.misc1 & shSCRIPT))
6063 return i;
6064
6065 reflect = ((shield.misc2 & shSCRIPT) != 0);
6066 }
6067
6068 break;
6069 }
6070
6071
3/4
✓ Branch 0 taken 1097 times.
✓ Branch 1 taken 2615 times.
✓ Branch 2 taken 1097 times.
✗ Branch 3 not taken.
3712 if(reflect && (ew->unblockable&WPNUNB_REFL))
6072 reflect = false;
6073
3/4
✓ Branch 0 taken 2615 times.
✓ Branch 1 taken 1097 times.
✓ Branch 2 taken 2615 times.
✗ Branch 3 not taken.
3712 if(!reflect && (ew->unblockable&WPNUNB_SHLD))
6074 return i;
6075
6076 3712 int32_t oldid = ew->id;
6077 3712 ew->onhit(false, reflect ? 2 : 1, dir);
6078
6079
2/2
✓ Branch 0 taken 2615 times.
✓ Branch 1 taken 1097 times.
3712 if(ew->id != oldid) // changed type from ewX to wX
6080 {
6081 // ew->power*=game->get_hero_dmgmult();
6082 1097 Lwpns.add(ew);
6083 1097 Ewpns.remove(ew);
6084 1097 ew->isLWeapon = true; //Make sure this gets set everywhere!
6085 1097 }
6086
6087
2/2
✓ Branch 0 taken 3373 times.
✓ Branch 1 taken 339 times.
3712 if(ew->id==wRefMagic)
6088 {
6089 339 ew->ignoreHero=true;
6090 339 ew->ignorecombo=-1;
6091 339 }
6092
6093 3712 sfx(shield.usesound,pan(x.getInt()));
6094 3712 }
6095 4050974 }
6096
6097 5749196 return -1;
6098 5752087 }
6099
6100 5752089 int32_t HeroClass::LwpnHit() //only here to check magic hits
6101 {
6102
2/2
✓ Branch 0 taken 5642900 times.
✓ Branch 1 taken 2348268 times.
7991168 for(int32_t i=0; i<Lwpns.Count(); i++)
6103
2/2
✓ Branch 0 taken 2239079 times.
✓ Branch 1 taken 109189 times.
2348268 if(Lwpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6104 {
6105 109189 weapon *lw = (weapon*)(Lwpns.spr(i));
6106
6107
2/2
✓ Branch 0 taken 105952 times.
✓ Branch 1 taken 3237 times.
109189 if((lw->ignoreHero)==true)
6108 3237 break;
6109
6110
5/8
✓ Branch 0 taken 105952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105950 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 105950 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 105950 times.
105952 if (!(lw->id == wRefFireball || lw->id == wRefMagic || lw->id == wRefBeam || lw->id == wRefRock)) return -1;
6111 2 int32_t itemid = getCurrentShield(false);
6112
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
6113 return i;
6114 2 itemdata const& shield = itemsbuf[itemid];
6115 2 auto cmpdir = compareDir(lw->dir);
6116 2 bool hitshield = compareShield(cmpdir, shield);
6117 2 bool reflect = false;
6118
6119
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 switch(lw->id)
6120 {
6121 case wRefFireball:
6122 if(itemid<0)
6123 return i;
6124
6125 if(lw->type & 1) //Boss fireball
6126 return i;
6127
6128 if(!(shield.misc1 & (shFIREBALL)))
6129 return i;
6130
6131 reflect = ((shield.misc2 & shFIREBALL) != 0);
6132 break;
6133
6134 case wRefMagic:
6135
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemid<0)
6136 return i;
6137
6138
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!(shield.misc1 & shMAGIC))
6139 return i;
6140
6141 2 reflect = ((shield.misc2 & shMAGIC) != 0);
6142 2 break;
6143
6144 case wRefBeam:
6145 if(itemid<0)
6146 return i;
6147
6148 if(!(shield.misc1 & shSWORD))
6149 return i;
6150
6151 reflect = ((shield.misc2 & shSWORD) != 0);
6152 break;
6153
6154 case wRefRock:
6155 if(itemid<0)
6156 return i;
6157
6158 if(!(shield.misc1 & shROCK))
6159 return i;
6160
6161 reflect = (shield.misc2 & shROCK);
6162 break;
6163
6164 default:
6165 return -1;
6166 }
6167
6168 2 bool allow_inactive = (shield.flags & ITEM_FLAG9);
6169
10/20
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 2 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 2 times.
✗ Branch 19 not taken.
2 if(!allow_inactive && ((lift_wpn && (liftflags & LIFTFL_DIS_SHIELD)) || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF))
6170 return i;
6171
6172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!hitshield)
6173 2 return i;
6174
6175 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6176
6177 paymagiccost(itemid);
6178
6179 lw->onhit(false, 1+reflect, dir);
6180 lw->ignoreHero=true;
6181 lw->ignorecombo=-1;
6182 sfx(shield.usesound,pan(x.getInt()));
6183 }
6184
6185 5646137 return -1;
6186 5752089 }
6187
6188 10114899 void HeroClass::checkhit()
6189 {
6190
2/2
✓ Branch 0 taken 3694976 times.
✓ Branch 1 taken 6419923 times.
10114899 if(checkhero==true)
6191 {
6192
2/2
✓ Branch 0 taken 320949 times.
✓ Branch 1 taken 6098974 times.
6419923 if(hclk>0)
6193 {
6194 320949 --hclk;
6195 320949 }
6196
6197
1/2
✓ Branch 0 taken 6419923 times.
✗ Branch 1 not taken.
6419923 if(DivineProtectionShieldClk>0)
6198 {
6199 --DivineProtectionShieldClk;
6200
6201 if(DivineProtectionShieldClk == 0 && div_prot_item != -1)
6202 {
6203 stop_sfx(itemsbuf[div_prot_item].usesound);
6204 stop_sfx(itemsbuf[div_prot_item].usesound+1);
6205 div_prot_item = -1;
6206 }
6207 else if(get_bit(quest_rules,qr_MORESOUNDS) && !(DivineProtectionShieldClk&0xF00) && div_prot_item != -1)
6208 {
6209 stop_sfx(itemsbuf[div_prot_item].usesound);
6210 cont_sfx(itemsbuf[div_prot_item].usesound+1);
6211 }
6212 }
6213 6419923 }
6214
6215
4/4
✓ Branch 0 taken 6358924 times.
✓ Branch 1 taken 3755975 times.
✓ Branch 2 taken 6355200 times.
✓ Branch 3 taken 3724 times.
10114899 if(hclk<39 && action==gothit)
6216 {
6217 3724 action=none; FFCore.setHeroAction(none);
6218 3724 }
6219
6220
5/6
✓ Branch 0 taken 6358924 times.
✓ Branch 1 taken 3755975 times.
✓ Branch 2 taken 6358872 times.
✓ Branch 3 taken 52 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6358872 times.
10114899 if(hclk<39 && (action==swimhit || action == sideswimhit))
6221 {
6222 52 SetSwim();
6223 52 }
6224
6225
4/4
✓ Branch 0 taken 54244 times.
✓ Branch 1 taken 10060655 times.
✓ Branch 2 taken 14607 times.
✓ Branch 3 taken 39637 times.
10114899 if(hclk>=40 && action==gothit)
6226 {
6227 39637 int val = check_pitslide();
6228
4/4
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 39355 times.
✓ Branch 2 taken 39757 times.
✓ Branch 3 taken 39475 times.
39637 if(((ladderx+laddery) && ((hitdir&2)==ladderdir))||(!(ladderx+laddery)))
6229 {
6230
2/2
✓ Branch 0 taken 159028 times.
✓ Branch 1 taken 39757 times.
198785 for(int32_t i=0; i<4; i++)
6231 {
6232
5/5
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 34568 times.
✓ Branch 2 taken 38280 times.
✓ Branch 3 taken 41084 times.
✓ Branch 4 taken 44904 times.
159028 switch(hitdir)
6233 {
6234 case up:
6235
6/6
✓ Branch 0 taken 2184 times.
✓ Branch 1 taken 32384 times.
✓ Branch 2 taken 2230 times.
✓ Branch 3 taken 30154 times.
✓ Branch 4 taken 2196 times.
✓ Branch 5 taken 32372 times.
34568 if(hit_walkflag(x,y+(bigHitbox?-1:7),2)||(x.getInt()&7?hit_walkflag(x+16,y+(bigHitbox?-1:7),1):0))
6236 {
6237 2196 action=none; FFCore.setHeroAction(none);
6238 2196 }
6239
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 32368 times.
32372 else if (val == -1) --y;
6240
6241 34568 break;
6242
6243 case down:
6244
6/6
✓ Branch 0 taken 3031 times.
✓ Branch 1 taken 35249 times.
✓ Branch 2 taken 2296 times.
✓ Branch 3 taken 32953 times.
✓ Branch 4 taken 3059 times.
✓ Branch 5 taken 35221 times.
38280 if(hit_walkflag(x,y+16,2)||(x.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6245 {
6246 3059 action=none; FFCore.setHeroAction(none);
6247 3059 }
6248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35221 times.
35221 else if (val == -1) ++y;
6249
6250 38280 break;
6251
6252 case left:
6253
7/8
✓ Branch 0 taken 39695 times.
✓ Branch 1 taken 1389 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39695 times.
✓ Branch 4 taken 926 times.
✓ Branch 5 taken 38769 times.
✓ Branch 6 taken 1393 times.
✓ Branch 7 taken 39691 times.
41084 if(hit_walkflag(x-1,y+(bigHitbox?0:8),1)||hit_walkflag(x-1,y+8,1)||(y.getInt()&7?hit_walkflag(x-1,y+16,1):0))
6254 {
6255 1393 action=none; FFCore.setHeroAction(none);
6256 1393 }
6257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39691 times.
39691 else if (val == -1) --x;
6258
6259 41084 break;
6260
6261 case right:
6262
7/8
✓ Branch 0 taken 43202 times.
✓ Branch 1 taken 1702 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 43202 times.
✓ Branch 4 taken 42593 times.
✓ Branch 5 taken 609 times.
✓ Branch 6 taken 1714 times.
✓ Branch 7 taken 43190 times.
44904 if(hit_walkflag(x+16,y+(bigHitbox?0:8),1)||hit_walkflag(x+16,y+8,1)||(y.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6263 {
6264 1714 action=none; FFCore.setHeroAction(none);
6265 1714 }
6266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43190 times.
43190 else if (val == -1) ++x;
6267
6268 44904 break;
6269 }
6270 159028 }
6271 39757 }
6272 39877 }
6273
6274
18/20
✓ Branch 0 taken 6105545 times.
✓ Branch 1 taken 4009594 times.
✓ Branch 2 taken 6105346 times.
✓ Branch 3 taken 199 times.
✓ Branch 4 taken 6095646 times.
✓ Branch 5 taken 9700 times.
✓ Branch 6 taken 6095006 times.
✓ Branch 7 taken 640 times.
✓ Branch 8 taken 6095006 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6095006 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6094858 times.
✓ Branch 13 taken 148 times.
✓ Branch 14 taken 6090979 times.
✓ Branch 15 taken 3879 times.
✓ Branch 16 taken 4915 times.
✓ Branch 17 taken 6086064 times.
✓ Branch 18 taken 4328887 times.
✓ Branch 19 taken 4333802 times.
10115139 if(hclk>0 || inlikelike == 1 || action==inwind || action==drowning || action==lavadrowning || action==sidedrowning || inwallm || isDiving() || (action==hopping && hopclk<255))
6275 {
6276 8353047 return;
6277 }
6278
6279
2/2
✓ Branch 0 taken 6871112 times.
✓ Branch 1 taken 6085965 times.
12957077 for(int32_t i=0; i<Lwpns.Count(); i++)
6280 {
6281 6871112 sprite *s = Lwpns.spr(i);
6282 6871112 int32_t itemid = ((weapon*)(Lwpns.spr(i)))->parentitem;
6283 //if ( itemdbuf[parentitem].flags&ITEM_FLAGS3 ) //can damage Hero
6284 //if ( itemsbuf[parentitem].misc1 > 0 ) //damages Hero by this amount.
6285
13/14
✓ Branch 0 taken 396935 times.
✓ Branch 1 taken 6474177 times.
✓ Branch 2 taken 2140375 times.
✓ Branch 3 taken 4333802 times.
✓ Branch 4 taken 2140375 times.
✓ Branch 5 taken 2193427 times.
✓ Branch 6 taken 2116200 times.
✓ Branch 7 taken 77227 times.
✓ Branch 8 taken 2116200 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 80797 times.
✓ Branch 11 taken 2035403 times.
✓ Branch 12 taken 40325 times.
✓ Branch 13 taken 41840 times.
6871112 if((!(itemid==-1&&get_bit(quest_rules,qr_FIREPROOFHERO)||((itemid>-1&&itemsbuf[itemid].family==itype_candle||itemsbuf[itemid].family==itype_book)&&(itemsbuf[itemid].flags & ITEM_FLAG3)))) && (scriptcoldet&1) && !fallclk && (!superman || !get_bit(quest_rules,qr_FIREPROOFHERO2)))
6286 {
6287
9/10
✓ Branch 0 taken 2005284 times.
✓ Branch 1 taken 71959 times.
✓ Branch 2 taken 71610 times.
✓ Branch 3 taken 349 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 349 times.
✓ Branch 6 taken 360 times.
✓ Branch 7 taken 71250 times.
✓ Branch 8 taken 2076534 times.
✓ Branch 9 taken 25 times.
2077268 if(s->id==wFire && (superman ? (diagonalMovement?s->hit(x+4,y+4-fakez,z,7,7,1):s->hit(x+7,y+7-fakez,z,2,2,1)) : s->hit(this))&&
6288
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
709 (itemid < 0 || itemsbuf[itemid].family!=itype_divinefire))
6289 {
6290 25 std::vector<int32_t> &ev = FFCore.eventData;
6291 25 ev.clear();
6292 25 ev.push_back(lwpn_dp(i)*10000);
6293 25 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6294 25 ev.push_back(0);
6295 25 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6296 25 ev.push_back(48*10000);
6297 25 ev.push_back(ZSD_LWPN*10000);
6298 25 ev.push_back(s->getUID());
6299
6300 25 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6301 25 int32_t dmg = ev[0]/10000;
6302 25 bool nullhit = ev[2] != 0;
6303
6304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(nullhit) {ev.clear(); return;}
6305
6306 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6307 25 ev[0] = ringpower(dmg)*10000;
6308
6309 25 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6310 25 dmg = ev[0]/10000;
6311 25 int32_t hdir = ev[1]/10000;
6312 25 nullhit = ev[2] != 0;
6313 25 bool divineprot = ev[3] != 0;
6314 25 int32_t iframes = ev[4] / 10000;
6315 25 ev.clear();
6316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(nullhit) return;
6317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!divineprot)
6318 {
6319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 game->set_life(zc_max(game->get_life()-dmg,0));
6320
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if (!get_bit(quest_rules, qr_BROKENHITBY))
6321 {
6322 sethitHeroUID(HIT_BY_LWEAPON,(i+1));
6323 if (get_bit(quest_rules, qr_BROKENHITBY))
6324 {
6325 sethitHeroUID(HIT_BY_LWEAPON_UID,((weapon*)(Lwpns.spr(i)))->getUID());
6326 }
6327 else
6328 {
6329
6330 sethitHeroUID(HIT_BY_LWEAPON_UID,((weapon*)(Lwpns.spr(i)))->getScriptUID());
6331 }
6332 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,((weapon*)(Lwpns.spr(i)))->getUID());
6333 sethitHeroUID(HIT_BY_LWEAPON_TYPE, ((weapon*)(Lwpns.spr(i)))->id);
6334 if (((weapon*)(Lwpns.spr(i)))->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, ((weapon*)(Lwpns.spr(i)))->parentitem);
6335 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6336 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[((weapon*)(Lwpns.spr(i)))->parentitem].family);
6337 }
6338 25 }
6339
6340 25 hitdir = hdir;
6341
6342
3/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
25 if (action != rafting && action != freeze && action != sideswimfreeze)
6343 {
6344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if (IsSideSwim())
6345 {
6346 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6347 }
6348
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 else if (action == swimming || hopclk == 0xFF)
6349 {
6350 action=swimhit; FFCore.setHeroAction(swimhit);
6351 }
6352 else
6353 {
6354 25 action=gothit; FFCore.setHeroAction(gothit);
6355 }
6356 25 }
6357
6358
5/8
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
25 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6359 {
6360 5 spins = charging = attackclk = 0;
6361 5 attack=none;
6362 5 tapping = false;
6363 5 }
6364
6365 25 hclk=iframes;
6366 25 sfx(getHurtSFX(),pan(x.getInt()));
6367 25 return;
6368 }
6369 2076534 }
6370
6371 // check enemy weapons true, 1, -1
6372 //
6373
2/2
✓ Branch 0 taken 2519504 times.
✓ Branch 1 taken 17781 times.
2591021 if((itemsbuf[itemid].flags & ITEM_FLAG6))
6374 {
6375
6/6
✓ Branch 0 taken 1717 times.
✓ Branch 1 taken 16064 times.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 1558 times.
✓ Branch 4 taken 59 times.
✓ Branch 5 taken 100 times.
17781 if(s->id==wBrang || (s->id==wHookshot&&!pull_hero))
6376 {
6377
1/2
✓ Branch 0 taken 16164 times.
✗ Branch 1 not taken.
16164 int32_t itemid = ((weapon*)s)->parentitem>-1 ? ((weapon*)s)->parentitem :
6378 directWpn>-1 ? directWpn : current_item_id(s->id==wHookshot ? (((weapon*)s)->family_class == itype_switchhook ? itype_switchhook : itype_hookshot) : itype_brang);
6379 16164 itemid = vbound(itemid, 0, MAXITEMS-1);
6380
6381
2/2
✓ Branch 0 taken 16160 times.
✓ Branch 1 taken 1039 times.
17199 for(int32_t j=0; j<Ewpns.Count(); j++)
6382 {
6383 1039 sprite *t = Ewpns.spr(j);
6384
6385
2/2
✓ Branch 0 taken 1035 times.
✓ Branch 1 taken 4 times.
1039 if(s->hit(t->x+7,t->y+7-t->fakez,t->z,2,2,1))
6386 {
6387 4 bool reflect = false;
6388 // sethitHeroUID(HIT_BY_EWEAPON,j); //set that Hero was hit by a specific eweapon index.
6389
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
4 switch(t->id)
6390 {
6391 case ewBrang:
6392 if(!(itemsbuf[itemid].misc3 & shBRANG)) break;
6393
6394 reflect = ((itemsbuf[itemid].misc4 & shBRANG) != 0);
6395 goto killweapon;
6396
6397 case ewArrow:
6398 if(!(itemsbuf[itemid].misc3 & shARROW)) break;
6399
6400 reflect = ((itemsbuf[itemid].misc4 & shARROW) != 0);
6401 goto killweapon;
6402
6403 case ewRock:
6404 if(!(itemsbuf[itemid].misc3 & shROCK)) break;
6405
6406 reflect = ((itemsbuf[itemid].misc4 & shROCK) != 0);
6407 goto killweapon;
6408
6409 case ewFireball2:
6410 case ewFireball:
6411 {
6412 int32_t mask = (((weapon*)t)->type&1 ? shFIREBALL2 : shFIREBALL);
6413
6414 if(!(itemsbuf[itemid].misc3 & mask)) break;
6415
6416 reflect = ((itemsbuf[itemid].misc4 & mask) != 0);
6417 goto killweapon;
6418 }
6419
6420 case ewSword:
6421 if(!(itemsbuf[itemid].misc3 & shSWORD)) break;
6422
6423 reflect = ((itemsbuf[itemid].misc4 & shSWORD) != 0);
6424 goto killweapon;
6425
6426 case wRefMagic:
6427 case ewMagic:
6428 if(!(itemsbuf[itemid].misc3 & shMAGIC)) break;
6429
6430 reflect = ((itemsbuf[itemid].misc4 & shMAGIC) != 0);
6431 goto killweapon;
6432
6433 case wScript1:
6434 case wScript2:
6435 case wScript3:
6436 case wScript4:
6437 case wScript5:
6438 case wScript6:
6439 case wScript7:
6440 case wScript8:
6441 case wScript9:
6442 case wScript10:
6443 if(!(itemsbuf[itemid].misc3 & shSCRIPT)) break;
6444
6445 reflect = ((itemsbuf[itemid].misc4 & shSCRIPT) != 0);
6446 goto killweapon;
6447
6448 case ewLitBomb:
6449 case ewLitSBomb:
6450 killweapon:
6451 ((weapon*)s)->dead=1;
6452 weapon *ew = ((weapon*)t);
6453 int32_t oldid = ew->id;
6454 ew->onhit(true, reflect ? 2 : 1, s->dir);
6455
6456 if(ew->id != oldid || (ew->id>=wScript1 && ew->id<=wScript10)) // changed type from ewX to wX... Except for script weapons
6457 {
6458 Lwpns.add(ew);
6459 Ewpns.remove(ew);
6460 ew->isLWeapon = true; //Make sure this gets set everywhere!
6461 }
6462
6463 if(ew->id==wRefMagic)
6464 {
6465 ew->ignoreHero=true;
6466 ew->ignorecombo=-1;
6467 }
6468
6469 break;
6470 }
6471
6472 4 break;
6473 }
6474 1035 }
6475 16164 }
6476 17781 }
6477
6478
6/6
✓ Branch 0 taken 1732960 times.
✓ Branch 1 taken 804325 times.
✓ Branch 2 taken 396935 times.
✓ Branch 3 taken 1336025 times.
✓ Branch 4 taken 32722 times.
✓ Branch 5 taken 364213 times.
2537285 if((itemsbuf[itemid].flags & ITEM_FLAG2)||(itemid==-1&&get_bit(quest_rules,qr_OUCHBOMBS)))
6479 {
6480
8/10
✓ Branch 0 taken 830343 times.
✓ Branch 1 taken 6704 times.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 837010 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 30 times.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 7 times.
837047 if(((s->id==wBomb)||(s->id==wSBomb)) && s->hit(this) && !superman && (scriptcoldet&1) && !fallclk)
6481 {
6482 7 std::vector<int32_t> &ev = FFCore.eventData;
6483 7 ev.clear();
6484
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 ev.push_back(((((weapon*)s)->parentitem>-1 ? itemsbuf[((weapon*)s)->parentitem].misc3 : ((weapon*)s)->power) *game->get_hp_per_heart())*10000);
6485 7 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6486 7 ev.push_back(0);
6487 7 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6488 7 ev.push_back(48*10000);
6489 7 ev.push_back(ZSD_LWPN*10000);
6490 7 ev.push_back(s->getUID());
6491
6492 7 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6493 7 int32_t dmg = ev[0]/10000;
6494 7 bool nullhit = ev[2] != 0;
6495
6496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(nullhit) {ev.clear(); return;}
6497
6498 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6499 7 ev[0] = ringpower(dmg)*10000;
6500
6501 7 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6502 7 dmg = ev[0]/10000;
6503 7 int32_t hdir = ev[1]/10000;
6504 7 nullhit = ev[2] != 0;
6505 7 bool divineprot = ev[3] != 0;
6506 7 int32_t iframes = ev[4] / 10000;
6507 7 ev.clear();
6508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(nullhit) return;
6509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(!divineprot)
6510 {
6511
3/6
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
7 game->set_life(zc_min(game->get_maxlife(), zc_max(game->get_life()-dmg,0)));
6512
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if (!get_bit(quest_rules, qr_BROKENHITBY))
6513 {
6514 sethitHeroUID(HIT_BY_LWEAPON,(i+1));
6515 if (get_bit(quest_rules, qr_BROKENHITBY))
6516 {
6517 sethitHeroUID(HIT_BY_LWEAPON_UID,((weapon*)(Lwpns.spr(i)))->getUID());
6518 }
6519 else
6520 {
6521
6522 sethitHeroUID(HIT_BY_LWEAPON_UID,((weapon*)(Lwpns.spr(i)))->getScriptUID());
6523 }
6524 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,((weapon*)(Lwpns.spr(i)))->getUID());
6525 sethitHeroUID(HIT_BY_LWEAPON_TYPE, ((weapon*)(Lwpns.spr(i)))->id);
6526 if (((weapon*)(Lwpns.spr(i)))->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, ((weapon*)(Lwpns.spr(i)))->parentitem);
6527 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6528 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[((weapon*)(Lwpns.spr(i)))->parentitem].family);
6529 }
6530 7 }
6531
6532 7 hitdir = hdir;
6533
6534
3/6
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7 times.
7 if (action != rafting && action != freeze && action != sideswimfreeze)
6535 {
6536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if (IsSideSwim())
6537 {
6538 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6539 }
6540
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
7 else if (action == swimming || hopclk == 0xFF)
6541 {
6542 action=swimhit; FFCore.setHeroAction(swimhit);
6543 }
6544 else
6545 {
6546 7 action=gothit; FFCore.setHeroAction(gothit);
6547 }
6548 7 }
6549
6550
4/8
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7 times.
7 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6551 {
6552 spins = charging = attackclk = 0;
6553 attack=none;
6554 tapping = false;
6555 }
6556
6557 7 hclk=iframes;
6558 7 sfx(getHurtSFX(),pan(x.getInt()));
6559 7 return;
6560 }
6561 837040 }
6562
6563
7/8
✓ Branch 0 taken 2537278 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6234 times.
✓ Branch 3 taken 2531044 times.
✓ Branch 4 taken 6167 times.
✓ Branch 5 taken 67 times.
✓ Branch 6 taken 2537211 times.
✓ Branch 7 taken 67 times.
2537278 if(hclk==0 && s->id==wWind && s->hit(x+7,y+7-fakez,z,2,2,1) && !fairyclk)
6564 {
6565 67 std::vector<int32_t> &ev = FFCore.eventData;
6566 67 ev.clear();
6567 67 ev.push_back(0);
6568 67 ev.push_back(s->dir*10000);
6569 67 ev.push_back(0);
6570 67 ev.push_back(0);
6571 67 ev.push_back(ZSD_LWPN*10000);
6572 67 ev.push_back(s->getUID());
6573
6574 67 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6575 67 bool nullhit = ev[2] != 0;
6576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(nullhit) {ev.clear(); return;}
6577
6578 67 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6579 67 int32_t hdir = ev[1]/10000;
6580 67 nullhit = ev[2] != 0;
6581 67 ev.clear();
6582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(nullhit) return;
6583
6584 67 reset_hookshot();
6585 67 xofs=1000;
6586 67 action=inwind; FFCore.setHeroAction(inwind);
6587 67 dir=s->dir=hdir;
6588 67 spins = charging = attackclk = 0;
6589
6590 // In case Hero used two whistles in a row, summoning two whirlwinds,
6591 // check which whistle's whirlwind picked him up so the correct
6592 // warp ring will be used
6593 67 int32_t whistle=((weapon*)s)->parentitem;
6594
6595
2/4
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 67 times.
67 if(whistle>-1 && itemsbuf[whistle].family==itype_whistle)
6596 67 whistleitem=whistle;
6597
6598 67 return;
6599 }
6600 2537211 }
6601
6602
6/8
✓ Branch 0 taken 6021966 times.
✓ Branch 1 taken 63999 times.
✓ Branch 2 taken 5917808 times.
✓ Branch 3 taken 104158 times.
✓ Branch 4 taken 5917808 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5917808 times.
12003773 if(action==rafting || action==freeze || action==sideswimfreeze ||
6603
4/8
✓ Branch 0 taken 5917808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5917808 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5917808 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5917808 times.
✗ Branch 7 not taken.
5917808 action==casting || action==sideswimcasting || action==drowning || action==lavadrowning || action==sidedrowning)
6604 168157 return;
6605
6606 5917808 int32_t hit2 = -1;
6607 5917808 do
6608 {
6609
2/2
✓ Branch 0 taken 685220 times.
✓ Branch 1 taken 5238438 times.
5923658 hit2 = diagonalMovement ? GuyHitFrom(hit2+1,x+4,y+4-fakez,z,8,8,hzsz)
6610 5238438 : GuyHitFrom(hit2+1,x+7,y+7-fakez,z,2,2,hzsz);
6611
6612
2/2
✓ Branch 0 taken 5909879 times.
✓ Branch 1 taken 13779 times.
5923658 if(hit2!=-1)
6613 {
6614
2/2
✓ Branch 0 taken 5850 times.
✓ Branch 1 taken 7929 times.
13779 if (hithero(hit2) == 0) return;
6615 5850 }
6616
2/2
✓ Branch 0 taken 5850 times.
✓ Branch 1 taken 5909879 times.
5915729 } while (hit2 != -1);
6617
6/6
✓ Branch 0 taken 5768336 times.
✓ Branch 1 taken 141543 times.
✓ Branch 2 taken 5752262 times.
✓ Branch 3 taken 16074 times.
✓ Branch 4 taken 173 times.
✓ Branch 5 taken 5752089 times.
5909879 if (superman || !(scriptcoldet&1) || fallclk) return;
6618 5752089 hit2 = LwpnHit();
6619
6620
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5752087 times.
5752089 if(hit2!=-1)
6621 {
6622 2 weapon* lwpnspr = (weapon*)Lwpns.spr(hit2);
6623 2 std::vector<int32_t> &ev = FFCore.eventData;
6624 2 ev.clear();
6625 2 ev.push_back((lwpn_dp(hit2)*10000));
6626 2 ev.push_back(lwpnspr->hitdir(x,y,16,16,dir)*10000);
6627 2 ev.push_back(0);
6628 2 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6629 2 ev.push_back(48*10000);
6630 2 ev.push_back(ZSD_LWPN*10000);
6631 2 ev.push_back(lwpnspr->getUID());
6632
6633 2 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6634 2 int32_t dmg = ev[0]/10000;
6635 2 bool nullhit = ev[2] != 0;
6636
6637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(nullhit) {ev.clear(); return;}
6638
6639 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6640 2 ev[0] = ringpower(dmg)*10000;
6641
6642 2 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6643 2 dmg = ev[0]/10000;
6644 2 int32_t hdir = ev[1]/10000;
6645 2 nullhit = ev[2] != 0;
6646 2 bool divineprot = ev[3] != 0;
6647 2 int32_t iframes = ev[4] / 10000;
6648 2 ev.clear();
6649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(nullhit) return;
6650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!divineprot)
6651 {
6652
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 game->set_life(zc_max(game->get_life()-dmg,0));
6653 2 sethitHeroUID(HIT_BY_LWEAPON,(hit2+1));
6654
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (get_bit(quest_rules, qr_BROKENHITBY))
6655 {
6656 2 sethitHeroUID(HIT_BY_LWEAPON_UID,lwpnspr->getUID());
6657 2 }
6658 else
6659 {
6660
6661 sethitHeroUID(HIT_BY_LWEAPON_UID,lwpnspr->getScriptUID());
6662 }
6663 2 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,lwpnspr->getUID());
6664 2 sethitHeroUID(HIT_BY_LWEAPON_TYPE, lwpnspr->id);
6665
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (lwpnspr->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, lwpnspr->parentitem);
6666 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6667 2 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[lwpnspr->parentitem].family);
6668 2 }
6669
6670 2 hitdir = hdir;
6671 2 lwpnspr->onhit(false);
6672
6673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (IsSideSwim())
6674 {
6675 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6676 }
6677
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 else if(action==swimming || hopclk==0xFF)
6678 {
6679 action=swimhit; FFCore.setHeroAction(swimhit);
6680 }
6681 else
6682 {
6683 2 action=gothit; FFCore.setHeroAction(gothit);
6684 }
6685
6686 2 hclk=iframes;
6687
6688
4/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
2 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6689 {
6690 spins = charging = attackclk = 0;
6691 attack=none;
6692 tapping = false;
6693 }
6694
6695 2 sfx(getHurtSFX(),pan(x.getInt()));
6696 2 return;
6697 }
6698
6699 //else { sethitHeroUID(HIT_BY_LWEAPON,(0)); //fails to clear
6700
6701 5752087 hit2 = EwpnHit();
6702
6703
2/2
✓ Branch 0 taken 2890 times.
✓ Branch 1 taken 5749197 times.
5752087 if(hit2!=-1)
6704 {
6705 2890 weapon* ewpnspr = (weapon*)Ewpns.spr(hit2);
6706 2890 std::vector<int32_t> &ev = FFCore.eventData;
6707 2890 ev.clear();
6708 2890 ev.push_back((ewpn_dp(hit2)*10000));
6709 2890 ev.push_back(ewpnspr->hitdir(x,y,16,16,dir)*10000);
6710 2890 ev.push_back(0);
6711 2890 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6712 2890 ev.push_back(48*10000);
6713 2890 ev.push_back(ZSD_EWPN*10000);
6714 2890 ev.push_back(ewpnspr->getUID());
6715
6716 2890 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6717 2890 int32_t dmg = ev[0]/10000;
6718 2890 bool nullhit = ev[2] != 0;
6719
6720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2890 times.
2890 if(nullhit) {ev.clear(); return;}
6721
6722 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6723 2890 ev[0] = ringpower(dmg)*10000;
6724
6725 2890 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6726 2890 dmg = ev[0]/10000;
6727 2890 int32_t hdir = ev[1]/10000;
6728 2890 nullhit = ev[2] != 0;
6729 2890 bool divineprot = ev[3] != 0;
6730 2890 int32_t iframes = ev[4] / 10000;
6731 2890 ev.clear();
6732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2890 times.
2890 if(nullhit) return;
6733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2890 times.
2890 if(!divineprot)
6734 {
6735
2/2
✓ Branch 0 taken 2871 times.
✓ Branch 1 taken 19 times.
2890 game->set_life(zc_max(game->get_life()-dmg,0));
6736 2890 sethitHeroUID(HIT_BY_EWEAPON,(hit2+1));
6737
1/2
✓ Branch 0 taken 2890 times.
✗ Branch 1 not taken.
2890 if (get_bit(quest_rules, qr_BROKENHITBY))
6738 {
6739 2890 sethitHeroUID(HIT_BY_EWEAPON_UID,ewpnspr->getUID());
6740 2890 }
6741 else
6742 {
6743
6744 sethitHeroUID(HIT_BY_EWEAPON_UID,ewpnspr->getScriptUID());
6745 }
6746 2890 sethitHeroUID(HIT_BY_EWEAPON_ENGINE_UID,ewpnspr->getUID());
6747 2890 sethitHeroUID(HIT_BY_EWEAPON_TYPE, ewpnspr->id);
6748 2890 }
6749
6750 2890 hitdir = hdir;
6751 2890 ewpnspr->onhit(false);
6752
6753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2890 times.
2890 if (IsSideSwim())
6754 {
6755 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6756 }
6757
3/4
✓ Branch 0 taken 2861 times.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2861 times.
2890 else if(action==swimming || hopclk==0xFF)
6758 {
6759 29 action=swimhit; FFCore.setHeroAction(swimhit);
6760 29 }
6761 else
6762 {
6763 2861 action=gothit; FFCore.setHeroAction(gothit);
6764 }
6765
6766 2890 hclk=iframes;
6767
6768
7/8
✓ Branch 0 taken 2887 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2887 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1006 times.
✓ Branch 5 taken 1881 times.
✓ Branch 6 taken 53 times.
✓ Branch 7 taken 953 times.
2890 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6769 {
6770 1937 spins = charging = attackclk = 0;
6771 1937 attack=none;
6772 1937 tapping = false;
6773 1937 }
6774
6775 2890 sfx(getHurtSFX(),pan(x.getInt()));
6776 2890 return;
6777 }
6778
6779 // The rest of this method deals with damage combos, which can be jumped over.
6780
4/4
✓ Branch 0 taken 5745929 times.
✓ Branch 1 taken 3268 times.
✓ Branch 2 taken 5745929 times.
✓ Branch 3 taken 3268 times.
5749197 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) return;
6781
6782 5745929 int32_t dx1 = (int32_t)x+8-(tmpscr->csensitive);
6783 5745929 int32_t dx2 = (int32_t)x+8+(tmpscr->csensitive-1);
6784
2/2
✓ Branch 0 taken 47666 times.
✓ Branch 1 taken 5698263 times.
5745929 int32_t dy1 = (int32_t)y+(bigHitbox?8:12)-(bigHitbox?tmpscr->csensitive:(tmpscr->csensitive+1)/2);
6785
2/2
✓ Branch 0 taken 47666 times.
✓ Branch 1 taken 5698263 times.
5745929 int32_t dy2 = (int32_t)y+(bigHitbox?8:12)+(bigHitbox?tmpscr->csensitive-1:((tmpscr->csensitive+1)/2)-1);
6786
6787
2/2
✓ Branch 0 taken 5745929 times.
✓ Branch 1 taken 9657547 times.
15403476 for(int32_t i=get_bit(quest_rules, qr_DMGCOMBOLAYERFIX) ? 1 : -1; i>=-1; i--) // Layers 0, 1 and 2!!
6788 9657547 (void)checkdamagecombos(dx1,dx2,dy1,dy2,i);
6789 6419923 }
6790
6791 3582 bool HeroClass::checkdamagecombos(int32_t dx, int32_t dy)
6792 {
6793 3582 return checkdamagecombos(dx,dx,dy,dy);
6794 }
6795
6796 114 void HeroClass::doHit(int32_t hdir)
6797 {
6798 114 hitdir = hdir;
6799
6800
3/6
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 114 times.
114 if (action != rafting && action != freeze && action != sideswimfreeze)
6801 {
6802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if (IsSideSwim())
6803 {
6804 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6805 }
6806
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 else if (action == swimming || hopclk == 0xFF)
6807 {
6808 action=swimhit; FFCore.setHeroAction(swimhit);
6809 }
6810 else
6811 {
6812 114 action=gothit; FFCore.setHeroAction(gothit);
6813 }
6814 114 }
6815
6816 114 hclk=48;
6817
6818
5/8
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75 times.
✓ Branch 5 taken 39 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 75 times.
114 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6819 {
6820 39 spins = charging = attackclk = 0;
6821 39 attack=none;
6822 39 tapping = false;
6823 39 }
6824
6825 114 sfx(getHurtSFX(),pan(x.getInt()));
6826 114 }
6827
6828 10552169 bool HeroClass::checkdamagecombos(int32_t dx1, int32_t dx2, int32_t dy1, int32_t dy2, int32_t layer, bool solid, bool do_health_check) //layer = -1, solid = false, do_health_check = true
6829 {
6830
5/6
✓ Branch 0 taken 10552156 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 10547270 times.
✓ Branch 3 taken 4886 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10547270 times.
10552169 if(hclk || superman || fallclk)
6831 4899 return false;
6832
6833 10547270 int32_t hp_mod[4] = {0};
6834 int32_t cid[8];
6835 10547270 byte hasKB = 0;
6836
6837 {
6838
2/2
✓ Branch 0 taken 4502315 times.
✓ Branch 1 taken 6044955 times.
10547270 cid[0] = layer>-1?MAPCOMBO2(layer,dx1,dy1):MAPCOMBO(dx1,dy1);
6839 10547270 newcombo& cmb = combobuf[cid[0]];
6840
4/4
✓ Branch 0 taken 10547267 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 10547123 times.
✓ Branch 3 taken 144 times.
10547270 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6841 {
6842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(cmb.usrflags&cflag1)
6843 hp_mod[0] = cmb.attributes[0] / -10000L;
6844 else
6845 144 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
6846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!(cmb.usrflags&cflag2))
6847 144 hasKB |= 1<<0;
6848 144 }
6849 }
6850 {
6851
2/2
✓ Branch 0 taken 4502315 times.
✓ Branch 1 taken 6044955 times.
10547270 cid[1] = layer>-1?MAPCOMBO2(layer,dx1,dy2):MAPCOMBO(dx1,dy2);
6852 10547270 newcombo& cmb = combobuf[cid[1]];
6853
4/4
✓ Branch 0 taken 10547267 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 10547106 times.
✓ Branch 3 taken 161 times.
10547270 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6854 {
6855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161 times.
161 if(cmb.usrflags&cflag1)
6856 hp_mod[1] = cmb.attributes[0] / -10000L;
6857 else
6858 161 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
6859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161 times.
161 if(!(cmb.usrflags&cflag2))
6860 161 hasKB |= 1<<1;
6861 161 }
6862 }
6863 {
6864
2/2
✓ Branch 0 taken 4502315 times.
✓ Branch 1 taken 6044955 times.
10547270 cid[2] = layer>-1?MAPCOMBO2(layer,dx2,dy1):MAPCOMBO(dx2,dy1);
6865 10547270 newcombo& cmb = combobuf[cid[2]];
6866
4/4
✓ Branch 0 taken 10547267 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 10547132 times.
✓ Branch 3 taken 135 times.
10547270 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6867 {
6868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
135 if(cmb.usrflags&cflag1)
6869 hp_mod[2] = cmb.attributes[0] / -10000L;
6870 else
6871 135 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
6872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
135 if(!(cmb.usrflags&cflag2))
6873 135 hasKB |= 1<<2;
6874 135 }
6875 }
6876 {
6877
2/2
✓ Branch 0 taken 4502315 times.
✓ Branch 1 taken 6044955 times.
10547270 cid[3] = layer>-1?MAPCOMBO2(layer,dx2,dy2):MAPCOMBO(dx2,dy2);
6878 10547270 newcombo& cmb = combobuf[cid[3]];
6879
4/4
✓ Branch 0 taken 10547267 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 10547117 times.
✓ Branch 3 taken 150 times.
10547270 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6880 {
6881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
150 if(cmb.usrflags&cflag1)
6882 hp_mod[3] = cmb.attributes[0] / -10000L;
6883 else
6884 150 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
6885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
150 if(!(cmb.usrflags&cflag2))
6886 150 hasKB |= 1<<3;
6887 150 }
6888 }
6889
6890 10547270 int32_t bestcid=0;
6891 10547270 int32_t hp_modtotal=0;
6892
2/2
✓ Branch 0 taken 7668726 times.
✓ Branch 1 taken 2878544 times.
10547270 if (!_effectflag(dx1,dy1,1, layer)) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6893
2/2
✓ Branch 0 taken 7663731 times.
✓ Branch 1 taken 2883539 times.
10547270 if (!_effectflag(dx1,dy2,1, layer)) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6894
2/2
✓ Branch 0 taken 7668758 times.
✓ Branch 1 taken 2878512 times.
10547270 if (!_effectflag(dx2,dy1,1, layer)) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6895
2/2
✓ Branch 0 taken 7663764 times.
✓ Branch 1 taken 2883506 times.
10547270 if (!_effectflag(dx2,dy2,1, layer)) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6896
6897
2/2
✓ Branch 0 taken 21094540 times.
✓ Branch 1 taken 10547270 times.
31641810 for (int32_t i = 0; i <= 1; ++i)
6898 {
6899
2/2
✓ Branch 0 taken 15688072 times.
✓ Branch 1 taken 5406468 times.
21094540 if(tmpscr2[i].valid!=0)
6900 {
6901
2/2
✓ Branch 0 taken 5024615 times.
✓ Branch 1 taken 381853 times.
5406468 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
6902 {
6903
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6904
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6905
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6906
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6907 5024615 }
6908 else
6909 {
6910
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 381502 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
381853 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6911
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 381502 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
381853 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6912
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 381502 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
381853 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6913
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 381502 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
381853 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6914 }
6915 5406468 }
6916 21094540 }
6917
6918
2/2
✓ Branch 0 taken 42189080 times.
✓ Branch 1 taken 10547270 times.
52736350 for(int32_t i=0; i<4; i++)
6919 {
6920
2/2
✓ Branch 0 taken 15524392 times.
✓ Branch 1 taken 26664688 times.
42189080 if(get_bit(quest_rules,qr_DMGCOMBOPRI))
6921 {
6922
2/2
✓ Branch 0 taken 15524232 times.
✓ Branch 1 taken 160 times.
15524392 if(hp_modtotal >= 0) //Okay, if it's over 0, it's healing Hero.
6923 {
6924
2/2
✓ Branch 0 taken 15524169 times.
✓ Branch 1 taken 63 times.
15524232 if(hp_mod[i] < hp_modtotal)
6925 {
6926 63 hp_modtotal = hp_mod[i];
6927 63 bestcid = cid[i];
6928 63 }
6929 15524232 }
6930
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 139 times.
160 else if(hp_mod[i] < 0) //If it's under 0, it's hurting Hero.
6931 {
6932
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(hp_mod[i] > hp_modtotal)
6933 {
6934 hp_modtotal = hp_mod[i];
6935 bestcid = cid[i];
6936 }
6937 139 }
6938 15524392 }
6939
2/2
✓ Branch 0 taken 26664571 times.
✓ Branch 1 taken 117 times.
26664688 else if(hp_mod[i] < hp_modtotal)
6940 {
6941 117 hp_modtotal = hp_mod[i];
6942 117 bestcid = cid[i];
6943 117 }
6944 42189080 }
6945
6946 {
6947 10547270 cid[4] = MAPFFCOMBO(dx1,dy1);
6948 10547270 newcombo& cmb = combobuf[cid[4]];
6949
4/4
✓ Branch 0 taken 10547075 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 10546188 times.
✓ Branch 3 taken 887 times.
10547270 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6950 {
6951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 887 times.
887 if(cmb.usrflags&cflag1 )
6952 hp_mod[0] = cmb.attributes[0]/10000L;
6953 else
6954 887 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
6955
1/2
✓ Branch 0 taken 887 times.
✗ Branch 1 not taken.
887 if(!(cmb.usrflags&cflag2))
6956 hasKB |= 1<<4;
6957 887 }
6958 }
6959 {
6960 10547270 cid[5] = MAPFFCOMBO(dx1,dy2);
6961 10547270 newcombo& cmb = combobuf[cid[5]];
6962
4/4
✓ Branch 0 taken 10547066 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 10546176 times.
✓ Branch 3 taken 890 times.
10547270 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6963 {
6964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 890 times.
890 if(cmb.usrflags&cflag1 )
6965 hp_mod[1] = cmb.attributes[0]/10000L;
6966 else
6967 890 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
6968
1/2
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
890 if(!(cmb.usrflags&cflag2))
6969 hasKB |= 1<<5;
6970 890 }
6971 }
6972 {
6973 10547270 cid[6] = MAPFFCOMBO(dx2,dy1);
6974 10547270 newcombo& cmb = combobuf[cid[6]];
6975
4/4
✓ Branch 0 taken 10547078 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 10546193 times.
✓ Branch 3 taken 885 times.
10547270 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6976 {
6977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 885 times.
885 if(cmb.usrflags&cflag1 )
6978 hp_mod[2] = cmb.attributes[0]/10000L;
6979 else
6980 885 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
6981
1/2
✓ Branch 0 taken 885 times.
✗ Branch 1 not taken.
885 if(!(cmb.usrflags&cflag2))
6982 hasKB |= 1<<6;
6983 885 }
6984 }
6985 {
6986 10547270 cid[7] = MAPFFCOMBO(dx2,dy2);
6987 10547270 newcombo& cmb = combobuf[cid[7]];
6988
4/4
✓ Branch 0 taken 10547069 times.
✓ Branch 1 taken 201 times.
✓ Branch 2 taken 10546181 times.
✓ Branch 3 taken 888 times.
10547270 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6989 {
6990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 888 times.
888 if(cmb.usrflags&cflag1 )
6991 hp_mod[3] = cmb.attributes[0]/10000L;
6992 else
6993 888 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
6994
1/2
✓ Branch 0 taken 888 times.
✗ Branch 1 not taken.
888 if(!(cmb.usrflags&cflag2))
6995 hasKB |= 1<<7;
6996 888 }
6997 }
6998
6999 10547270 int32_t bestffccid = 0;
7000 10547270 int32_t hp_modtotalffc = 0;
7001
7002
2/2
✓ Branch 0 taken 21094540 times.
✓ Branch 1 taken 10547270 times.
31641810 for (int32_t i = 0; i <= 1; ++i)
7003 {
7004
2/2
✓ Branch 0 taken 15688072 times.
✓ Branch 1 taken 5406468 times.
21094540 if(tmpscr2[i].valid!=0)
7005 {
7006
2/2
✓ Branch 0 taken 5024615 times.
✓ Branch 1 taken 381853 times.
5406468 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
7007 {
7008
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7009
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7010
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7011
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7012 5024615 }
7013 else
7014 {
7015
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 381502 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
381853 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7016
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 381502 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
381853 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7017
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 381502 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
381853 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7018
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 381502 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
381853 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7019 }
7020 5406468 }
7021 21094540 }
7022
7023
2/2
✓ Branch 0 taken 42189080 times.
✓ Branch 1 taken 10547270 times.
52736350 for(int32_t i=0; i<4; i++)
7024 {
7025
2/2
✓ Branch 0 taken 15524392 times.
✓ Branch 1 taken 26664688 times.
42189080 if(get_bit(quest_rules,qr_DMGCOMBOPRI))
7026 {
7027
2/2
✓ Branch 0 taken 15524232 times.
✓ Branch 1 taken 160 times.
15524392 if(hp_modtotalffc >= 0)
7028 {
7029
2/2
✓ Branch 0 taken 15524169 times.
✓ Branch 1 taken 63 times.
15524232 if(hp_mod[i] < hp_modtotalffc)
7030 {
7031 63 hp_modtotalffc = hp_mod[i];
7032 63 bestffccid = cid[4+i];
7033 63 }
7034 15524232 }
7035
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 139 times.
160 else if(hp_mod[i] < 0)
7036 {
7037
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(hp_mod[i] > hp_modtotalffc)
7038 {
7039 hp_modtotalffc = hp_mod[i];
7040 bestffccid = cid[4+i];
7041 }
7042 139 }
7043 15524392 }
7044
2/2
✓ Branch 0 taken 26663681 times.
✓ Branch 1 taken 1007 times.
26664688 else if(hp_mod[i] < hp_modtotalffc)
7045 {
7046 1007 hp_modtotalffc = hp_mod[i];
7047 1007 bestffccid = cid[4+i];
7048 1007 }
7049 42189080 }
7050
7051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10547270 times.
10547270 int32_t hp_modmin = zc_min(hp_modtotal, hp_modtotalffc);
7052
1/2
✓ Branch 0 taken 10547270 times.
✗ Branch 1 not taken.
10547270 if(hp_modtotalffc < hp_modmin) bestcid = bestffccid;
7053
7054 10547270 bool global_defring = ((itemsbuf[current_item_id(itype_ring)].flags & ITEM_FLAG1));
7055 10547270 bool global_perilring = ((itemsbuf[current_item_id(itype_perilring)].flags & ITEM_FLAG1));
7056 10547270 bool current_ring = ((tmpscr->flags6&fTOGGLERINGDAMAGE) != 0);
7057
1/2
✓ Branch 0 taken 10547270 times.
✗ Branch 1 not taken.
10547270 if(current_ring)
7058 {
7059 global_defring = !global_defring;
7060 global_perilring = !global_perilring;
7061 }
7062 10547270 int32_t itemid = current_item_id(itype_boots);
7063
7064
2/2
✓ Branch 0 taken 10089381 times.
✓ Branch 1 taken 457889 times.
10547270 bool bootsnosolid = itemid >= 0 && 0 != (itemsbuf[itemid].flags & ITEM_FLAG1);
7065
2/2
✓ Branch 0 taken 10089381 times.
✓ Branch 1 taken 457889 times.
10547270 bool ignoreBoots = itemid >= 0 && (itemsbuf[itemid].flags & ITEM_FLAG3);
7066
7067
2/2
✓ Branch 0 taken 10546200 times.
✓ Branch 1 taken 1070 times.
10547270 if(hp_modmin<0)
7068 {
7069
8/14
✓ Branch 0 taken 945 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 945 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 945 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 945 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 945 times.
✓ Branch 10 taken 945 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 945 times.
1070 if((itemid<0) || ignoreBoots || (tmpscr->flags5&fDAMAGEWITHBOOTS) || (4<<current_item_power(itype_boots)<(abs(hp_modmin))) || (solid && bootsnosolid) || !(checkbunny(itemid) && checkmagiccost(itemid)))
7070 {
7071
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 14 times.
125 if (!do_health_check) return true;
7072 111 std::vector<int32_t> &ev = FFCore.eventData;
7073 111 ev.clear();
7074 111 ev.push_back(-hp_modmin*10000);
7075
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 6 times.
111 ev.push_back((hasKB ? dir^1 : -1)*10000);
7076 111 ev.push_back(0);
7077 111 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7078 111 ev.push_back(48*10000);
7079 111 ev.push_back(ZSD_COMBODATA*10000);
7080 111 ev.push_back(bestcid);
7081
7082 111 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7083 111 int32_t dmg = ev[0]/10000;
7084 111 bool nullhit = ev[2] != 0;
7085
7086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(nullhit) {ev.clear(); return false;}
7087
7088 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7089 111 ev[0] = ringpower(dmg, !global_perilring, !global_defring)*10000;
7090
7091 111 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7092 111 dmg = ev[0]/10000;
7093 111 int32_t hdir = ev[1]/10000;
7094 111 nullhit = ev[2] != 0;
7095 111 bool divineprot = ev[3] != 0;
7096 111 int32_t iframes = ev[4] / 10000;
7097 111 ev.clear();
7098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(nullhit) return false;
7099
7100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(!divineprot)
7101 {
7102
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 3 times.
111 game->set_life(zc_max(game->get_life()-dmg,0));
7103 111 }
7104
7105 111 hitdir = hdir;
7106 111 doHit(hitdir);
7107 111 hclk = iframes;
7108 111 return true;
7109 }
7110
2/2
✓ Branch 0 taken 876 times.
✓ Branch 1 taken 69 times.
945 else if (do_health_check) paymagiccost(itemid); // Boots are successful
7111 945 }
7112
7113 10547145 return false;
7114 10552169 }
7115
7116 13860 int32_t HeroClass::hithero(int32_t hit2, int32_t force_hdir)
7117 {
7118
1/2
✓ Branch 0 taken 13860 times.
✗ Branch 1 not taken.
13860 if(force_hdir > 3) force_hdir = -1;
7119 13860 enemy* enemyptr = (enemy*)guys.spr(hit2);
7120
1/2
✓ Branch 0 taken 13860 times.
✗ Branch 1 not taken.
13860 if(!enemyptr) return 0;
7121 //printf("Stomp check: %d <= 12, %d < %d\n", int32_t((y+16)-(((enemy*)guys.spr(hit2))->y)), (int32_t)falling_oldy, (int32_t)y);
7122 13860 int32_t stompid = current_item_id(itype_stompboots);
7123
5/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 13845 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
13860 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
7124
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 ((z+fakez) > (enemyptr->z+(enemyptr->fakez))) ||
7125
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15 ((isSideViewHero() && (y+16)-(enemyptr->y)<=14) && falling_oldy<y)))
7126 {
7127 paymagiccost(stompid);
7128 hit_enemy(hit2,wStomp,itemsbuf[stompid].power*game->get_hero_dmgmult(),x,y,0,stompid);
7129
7130 if(itemsbuf[stompid].flags & ITEM_FLAG1)
7131 {
7132 fall = -(itemsbuf[stompid].misc1);
7133 }
7134
7135 if(itemsbuf[stompid].flags & ITEM_DOWNGRADE)
7136 game->set_item(stompid,false);
7137
7138 // Stomp Boots script
7139 if(itemsbuf[stompid].script != 0 && !(item_doscript[stompid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
7140 {
7141 //clear the item script stack for a new script
7142 ri = &(itemScriptData[stompid]);
7143 for ( int32_t q = 0; q < 1024; q++ ) item_stack[stompid][q] = 0xFFFF;
7144 ri->Clear();
7145 //itemScriptData[(stompid & 0xFFF)].Clear();
7146 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(stompid & 0xFFF)][q] = 0;
7147 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[stompid].script, stompid & 0xFFF);
7148 item_doscript[stompid] = 1;
7149 itemscriptInitialised[stompid] = 0;
7150 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[stompid].script, stompid);
7151 }
7152
7153 return -1;
7154 }
7155
5/6
✓ Branch 0 taken 10101 times.
✓ Branch 1 taken 3759 times.
✓ Branch 2 taken 9662 times.
✓ Branch 3 taken 439 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9662 times.
13860 else if(superman || !(scriptcoldet&1) || fallclk)
7156 4198 return 0;
7157 //!TODO SOLIDPUSH Enemy flag to make them not deal contact damage
7158 //!Add a flag check to this if:
7159
5/6
✓ Branch 0 taken 4029 times.
✓ Branch 1 taken 5633 times.
✓ Branch 2 taken 4029 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1827 times.
✓ Branch 5 taken 2202 times.
9662 else if (!(enemyptr->stunclk==0 && enemyptr->frozenclock==0 && (!get_bit(quest_rules, qr_SAFEENEMYFADE) || enemyptr->fading != fade_flicker)
7160
3/4
✓ Branch 0 taken 1584 times.
✓ Branch 1 taken 243 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3786 times.
4029 && (enemyptr->d->family != eeGUY || enemyptr->dmisc1)))
7161 {
7162 5876 return -1;
7163 }
7164
7165 3786 std::vector<int32_t> &ev = FFCore.eventData;
7166 3786 ev.clear();
7167 //Args: 'damage (pre-ring)','hitdir','nullifyhit','type:npc','npc uid'
7168 3786 ev.push_back((enemy_dp(hit2) *10000));
7169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3786 times.
3786 ev.push_back((force_hdir>-1 ? force_hdir : ((sprite*)enemyptr)->hitdir(x,y,16,16,dir))*10000);
7170 3786 ev.push_back(0);
7171 3786 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7172 3786 ev.push_back(48*10000);
7173 3786 ev.push_back(ZSD_NPC*10000);
7174 3786 ev.push_back(enemyptr->getUID());
7175
7176 3786 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7177 3786 int32_t dmg = ev[0] / 10000;
7178 3786 bool nullhit = ev[2] != 0;
7179
7180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3786 times.
3786 if(nullhit) {ev.clear(); return -1;}
7181
7182 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7183 3786 ev[0] = ((ringpower(dmg)*10000));
7184
7185 3786 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7186 3786 dmg = ev[0] / 10000;
7187 3786 int32_t hdir = ev[1] / 10000;
7188 3786 nullhit = ev[2] != 0;
7189 3786 bool divineprot = ev[3] != 0;
7190 3786 int32_t iframes = ev[4] / 10000;
7191 3786 ev.clear();
7192
7193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3786 times.
3786 if(nullhit) return -1;
7194
7195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3786 times.
3786 if(!divineprot)
7196 {
7197
2/2
✓ Branch 0 taken 3763 times.
✓ Branch 1 taken 23 times.
3786 game->set_life(zc_max(game->get_life()-dmg,0));
7198 3786 sethitHeroUID(HIT_BY_NPC,(hit2+1));
7199 3786 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7200
1/2
✓ Branch 0 taken 3786 times.
✗ Branch 1 not taken.
3786 if (get_bit(quest_rules, qr_BROKENHITBY))
7201 {
7202 3786 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7203 3786 }
7204 else
7205 {
7206 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->script_UID);
7207 }
7208 3786 sethitHeroUID(HIT_BY_NPC_ENGINE_UID,enemyptr->getUID());
7209 3786 sethitHeroUID(HIT_BY_NPC_ID, enemyptr->id);
7210 3786 sethitHeroUID(HIT_BY_NPC_TYPE, enemyptr->family);
7211 3786 }
7212
7213 3786 hitdir = hdir;
7214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3786 times.
3786 if (IsSideSwim())
7215 {
7216 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7217 }
7218
3/4
✓ Branch 0 taken 3754 times.
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3754 times.
3786 else if(action==swimming || hopclk==0xFF)
7219 {
7220 32 action=swimhit; FFCore.setHeroAction(swimhit);
7221 32 }
7222 else
7223 {
7224 3754 action=gothit; FFCore.setHeroAction(gothit);
7225 }
7226
7227 3786 hclk=iframes;
7228 3786 sfx(getHurtSFX(),pan(x.getInt()));
7229
7230
7/8
✓ Branch 0 taken 3784 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3784 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1554 times.
✓ Branch 5 taken 2230 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 1506 times.
3786 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7231 {
7232 2280 spins = charging = attackclk = 0;
7233 2280 attack=none;
7234 2280 tapping = false;
7235 2280 }
7236
7237 3786 enemy_scored(hit2);
7238 3786 int32_t dm7 = enemyptr->dmisc7;
7239 3786 int32_t dm8 = enemyptr->dmisc8;
7240
7241
3/3
✓ Branch 0 taken 1737 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2046 times.
3786 switch(enemyptr->family)
7242 {
7243 case eeWALLM:
7244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(enemyptr->hp>0)
7245 {
7246 3 GrabHero(hit2);
7247 3 inwallm=true;
7248 3 action=none; FFCore.setHeroAction(none);
7249 3 }
7250 3 break;
7251
7252 //case eBUBBLEST:
7253 //case eeBUBBLE:
7254 case eeWALK:
7255 {
7256 2046 int32_t itemid = current_item_id(itype_whispring);
7257 //I can only assume these are supposed to be int32_t, not bool ~pkmnfrk
7258
3/4
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 1886 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
2046 int32_t sworddivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 1) ? itemsbuf[itemid].power : 1);
7259
3/4
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 1886 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
2046 int32_t itemdivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 2) ? itemsbuf[itemid].power : 1);
7260
7261
5/7
✓ Branch 0 taken 1615 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 79 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21 times.
✗ Branch 6 not taken.
2046 switch(dm7)
7262 {
7263 case e7tTEMPJINX:
7264
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 258 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
277 if(dm8==0 || dm8==2)
7265
4/4
✓ Branch 0 taken 257 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 254 times.
512 if(swordclk>=0 && !(sworddivisor==0))
7266 254 swordclk=150;
7267
7268
3/4
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 258 times.
277 if(dm8==1 || dm8==2)
7269
3/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 18 times.
37 if(itemclk>=0 && !(itemdivisor==0))
7270 18 itemclk=150;
7271
7272 277 break;
7273
7274 case e7tPERMJINX:
7275
3/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
54 if(dm8==0 || dm8==2)
7276
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
38 if(sworddivisor) swordclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/sworddivisor) : -1;
7277
7278
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
54 if(dm8==1 || dm8==2)
7279
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
16 if(itemdivisor) itemclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/itemdivisor) : -1;
7280
7281 54 break;
7282
7283 case e7tUNJINX:
7284
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
79 if(dm8==0 || dm8==2)
7285 67 swordclk=0;
7286
7287
3/4
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 67 times.
79 if(dm8==1 || dm8==2)
7288 12 itemclk=0;
7289
7290 79 break;
7291
7292 case e7tTAKEMAGIC:
7293 game->change_dmagic(-dm8*game->get_magicdrainrate());
7294 break;
7295
7296 case e7tTAKERUPEES:
7297 21 game->change_drupy(-dm8);
7298 21 break;
7299
7300 case e7tDRUNK:
7301 drunkclk += dm8;
7302 break;
7303 }
7304 2046 verifyAWpn();
7305
2/2
✓ Branch 0 taken 1995 times.
✓ Branch 1 taken 51 times.
2046 if(dm7 >= e7tEATITEMS)
7306 {
7307 51 EatHero(hit2);
7308 51 inlikelike=(dm7 == e7tEATHURT ? 2:1);
7309 51 action=none; FFCore.setHeroAction(none);
7310 51 }
7311 }
7312 2046 }
7313 3786 return 0;
7314 13860 }
7315
7316 314009 void HeroClass::addsparkle(int32_t wpn)
7317 {
7318 //return;
7319 314009 weapon *w = (weapon*)Lwpns.spr(wpn);
7320 314009 int32_t itemid = w->parentitem;
7321
7322
2/2
✓ Branch 0 taken 310655 times.
✓ Branch 1 taken 3354 times.
314009 if(itemid<0)
7323 3354 return;
7324
7325 310655 int32_t itemtype = itemsbuf[itemid].family;
7326
7327
4/4
✓ Branch 0 taken 310582 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 77634 times.
✓ Branch 3 taken 232948 times.
310655 if(itemtype!=itype_cbyrna && frame%4)
7328 232948 return;
7329
7330
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 77634 times.
77707 int32_t wpn2 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn4 : itemsbuf[itemid].wpn2;
7331
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 77634 times.
77707 int32_t wpn3 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn5 : itemsbuf[itemid].wpn3;
7332 // Either one (wpn2) or the other (wpn3). If both are present, randomise.
7333
5/8
✓ Branch 0 taken 22591 times.
✓ Branch 1 taken 55116 times.
✓ Branch 2 taken 38407 times.
✓ Branch 3 taken 16709 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22591 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
77707 int32_t sparkle_type = (!wpn2 ? (!wpn3 ? 0 : wpn3) : (!wpn3 ? wpn2 : (zc_oldrand()&1 ? wpn2 : wpn3)));
7334 77707 int32_t direction=w->dir;
7335
7336
2/2
✓ Branch 0 taken 38407 times.
✓ Branch 1 taken 39300 times.
77707 if(sparkle_type)
7337 {
7338 39300 int32_t h=0;
7339 39300 int32_t v=0;
7340
7341
6/6
✓ Branch 0 taken 31465 times.
✓ Branch 1 taken 7835 times.
✓ Branch 2 taken 28007 times.
✓ Branch 3 taken 3458 times.
✓ Branch 4 taken 6095 times.
✓ Branch 5 taken 21912 times.
39300 if(w->dir==right||w->dir==r_up||w->dir==r_down)
7342 {
7343 17388 h=-1;
7344 17388 }
7345
7346
6/6
✓ Branch 0 taken 31738 times.
✓ Branch 1 taken 7562 times.
✓ Branch 2 taken 26489 times.
✓ Branch 3 taken 5249 times.
✓ Branch 4 taken 3934 times.
✓ Branch 5 taken 22555 times.
39300 if(w->dir==left||w->dir==l_up||w->dir==l_down)
7347 {
7348 16745 h=1;
7349 16745 }
7350
7351
6/6
✓ Branch 0 taken 37062 times.
✓ Branch 1 taken 2238 times.
✓ Branch 2 taken 33128 times.
✓ Branch 3 taken 3934 times.
✓ Branch 4 taken 6095 times.
✓ Branch 5 taken 27033 times.
39300 if(w->dir==down||w->dir==l_down||w->dir==r_down)
7352 {
7353 12267 v=-1;
7354 12267 }
7355
7356
6/6
✓ Branch 0 taken 36371 times.
✓ Branch 1 taken 2929 times.
✓ Branch 2 taken 31122 times.
✓ Branch 3 taken 5249 times.
✓ Branch 4 taken 3458 times.
✓ Branch 5 taken 27664 times.
39300 if(w->dir==up||w->dir==l_up||w->dir==r_up)
7357 {
7358 11636 v=1;
7359 11636 }
7360
7361 // Damaging boomerang sparkle?
7362
3/4
✓ Branch 0 taken 16709 times.
✓ Branch 1 taken 22591 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16709 times.
39300 if(wpn3 && itemtype==itype_brang)
7363 {
7364 // If the boomerang just bounced, flip the sparkle direction so it doesn't hit
7365 // whatever it just bounced off of if it's shielded from that direction.
7366
6/6
✓ Branch 0 taken 10964 times.
✓ Branch 1 taken 5745 times.
✓ Branch 2 taken 10517 times.
✓ Branch 3 taken 447 times.
✓ Branch 4 taken 4476 times.
✓ Branch 5 taken 6041 times.
16709 if(w->misc==1 && w->clk2>256 && w->clk2<272)
7367 6041 direction=oppositeDir[direction];
7368 16709 }
7369
4/4
✓ Branch 0 taken 38355 times.
✓ Branch 1 taken 945 times.
✓ Branch 2 taken 17684 times.
✓ Branch 3 taken 20671 times.
39300 if(itemtype==itype_brang && get_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR)) direction = 0;
7370
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 39227 times.
39300 zfix x = w->x+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(h*4);
7371
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 39227 times.
39300 zfix y = w->y+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(v*4)-w->fakez;
7372
5/10
✓ Branch 0 taken 39300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 39300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 39300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 39300 times.
✗ Branch 9 not taken.
39300 Lwpns.add(new weapon(x, y, w->z, sparkle_type==wpn3 ? wFSparkle : wSSparkle,sparkle_type,0,direction,itemid,getUID(),false,false,true, 0, sparkle_type));
7373 39300 weapon *w = (weapon*)(Lwpns.spr(Lwpns.Count()-1));
7374 39300 }
7375 314009 }
7376
7377 // For wPhantoms
7378 void HeroClass::addsparkle2(int32_t type1, int32_t type2)
7379 {
7380 if(frame%4) return;
7381
7382 int32_t arrow = -1;
7383
7384 for(int32_t i=0; i<Lwpns.Count(); i++)
7385 {
7386 weapon *w = (weapon*)Lwpns.spr(i);
7387
7388 if(w->id == wPhantom && w->type == type1)
7389 {
7390 arrow = i;
7391 break;
7392 }
7393 }
7394
7395 if(arrow==-1)
7396 {
7397 return;
7398 }
7399
7400 zfix x = (Lwpns.spr(arrow)->x-3)+(zc_oldrand()%7);
7401 zfix y = (Lwpns.spr(arrow)->y-3)+(zc_oldrand()%7)-Lwpns.spr(arrow)->fakez;
7402 Lwpns.add(new weapon(x, y, Lwpns.spr(arrow)->z, wPhantom, type2,0,0,((weapon*)Lwpns.spr(arrow))->parentitem,-1));
7403 }
7404
7405 //cleans up decorations that exit the bounds of the screen for a int32_t time, to prevebt them wrapping around.
7406 6419565 void HeroClass::PhantomsCleanup()
7407 {
7408
1/2
✓ Branch 0 taken 6419565 times.
✗ Branch 1 not taken.
6419565 if(Lwpns.idCount(wPhantom))
7409 {
7410 for(int32_t i=0; i<Lwpns.Count(); i++)
7411 {
7412 weapon *w = ((weapon *)Lwpns.spr(i));
7413 if ( w->id == wPhantom && !w->isScriptGenerated() )
7414 {
7415 if ( w->x < -10000 || w->y > 10000 || w->x < -10000 || w->y > 10000 )
7416 {
7417 Lwpns.remove(w);
7418 }
7419 }
7420 }
7421 }
7422 6419565 }
7423
7424 //Waitframe handler for refilling operations
7425 4932 static void do_refill_waitframe()
7426 {
7427 4932 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,game->should_show_time(),sspUP);
7428
1/2
✓ Branch 0 taken 4932 times.
✗ Branch 1 not taken.
4932 if(get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
7429 {
7430 script_drawing_commands.Clear();
7431 if(DMaps[currdmap].passive_sub_script != 0)
7432 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
7433 if(passive_subscreen_waitdraw && DMaps[currdmap].passive_sub_script != 0 && passive_subscreen_doscript != 0)
7434 {
7435 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
7436 passive_subscreen_waitdraw = false;
7437 }
7438 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
7439 }
7440 4932 advanceframe(true);
7441 4932 }
7442 //Special handler if it's a "fairy revive"
7443 static void do_death_refill_waitframe()
7444 {
7445 //!TODO Run a new script slot each frame here, before calling do_refill_waitframe()
7446 //This script should be able to draw a 'fairy saving the player' animation -Em
7447 do_refill_waitframe();
7448 }
7449
7450 static size_t find_bottle_for_slot(size_t slot, bool unowned=false)
7451 {
7452 int32_t found_unowned = -1;
7453 for(int q = 0; q < MAXITEMS; ++q)
7454 {
7455 if(itemsbuf[q].family == itype_bottle && itemsbuf[q].misc1 == slot)
7456 {
7457 if(game->get_item(q))
7458 return q;
7459 if(unowned)
7460 found_unowned = q;
7461 }
7462 }
7463 return found_unowned;
7464 }
7465
7466 int32_t getPushDir(int32_t flag)
7467 {
7468 switch(flag)
7469 {
7470 case mfPUSHUD: case mfPUSH4: case mfPUSHU: case mfPUSHUDNS:
7471 case mfPUSH4NS: case mfPUSHUNS: case mfPUSHUDINS: case mfPUSH4INS:
7472 case mfPUSHUINS:
7473 return up;
7474 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
7475 return down;
7476 case mfPUSHLR: case mfPUSHL: case mfPUSHLRNS: case mfPUSHLNS:
7477 case mfPUSHLRINS: case mfPUSHLINS:
7478 return left;
7479 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
7480 return right;
7481 }
7482 return -1;
7483 }
7484
7485 void post_item_collect();
7486
7487 6419924 bool HeroClass::handle_portal_collide(portal* p)
7488 {
7489
1/2
✓ Branch 0 taken 6419924 times.
✗ Branch 1 not taken.
6419924 if(!p) return false;
7490 6419924 p->animate(0);
7491
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6419924 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6419924 if(p->destdmap < 0 || p->destdmap >= MAXDMAPS)
7492 6419924 return false;
7493 if(abs(x - p->x) < 12
7494 && abs(y - p->y) < 12)
7495 {
7496 if(p->prox_active)
7497 {
7498 //Store some values to restore if 'warp fails'
7499 int32_t tLastEntrance = lastentrance,
7500 tLastEntranceDMap = lastentrance_dmap,
7501 tContScr = game->get_continue_scrn(),
7502 tContDMap = game->get_continue_dmap();
7503 int32_t sourcescr = currscr, sourcedmap = currdmap;
7504 zfix tx = x, ty = y, tz = z;
7505 x = p->x;
7506 y = p->y;
7507
7508 int32_t weff = p->weffect,
7509 wsfx = p->wsfx;
7510
7511 int32_t savep = p->saved_data;
7512 //After this line, 'p' becomes INVALID!
7513 FFCore.warp_player(wtIWARP, p->destdmap, p->destscr,
7514 -1, -1, weff, wsfx, 0, -1);
7515
7516 if(mirrorBonk()) //Invalid landing, warp back!
7517 {
7518 action = none; FFCore.setHeroAction(none);
7519 lastentrance = tLastEntrance;
7520 lastentrance_dmap = tLastEntranceDMap;
7521 game->set_continue_scrn(tContScr);
7522 game->set_continue_dmap(tContDMap);
7523 x = tx;
7524 y = ty;
7525 z = tz;
7526 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, weff,
7527 wsfx, 0, -1);
7528 handle_portal_prox(&mirror_portal);
7529 portals.forEach([&](sprite& p)
7530 {
7531 handle_portal_prox((portal*)&p);
7532 return false;
7533 });
7534 }
7535 else game->clear_portal(savep); //Remove portal once used
7536 return true;
7537 }
7538 }
7539 else p->prox_active = true;
7540 return false;
7541 6419924 }
7542 13 void HeroClass::handle_portal_prox(portal* p)
7543 {
7544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!p) return;
7545
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 3 times.
13 p->prox_active = !(abs(x - p->x) < 12 && abs(y - p->y) < 12);
7546 13 }
7547 // returns true when game over
7548 18715097 bool HeroClass::animate(int32_t)
7549 {
7550 18715097 int32_t lsave=0;
7551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18715097 times.
18715097 if(immortal > 0)
7552 --immortal;
7553 18715097 prompt_combo = 0;
7554
2/2
✓ Branch 0 taken 12295173 times.
✓ Branch 1 taken 6419924 times.
18715097 if (onpassivedmg)
7555 {
7556 12295173 onpassivedmg=false;
7557 12295173 }
7558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6419924 times.
6419924 else if (damageovertimeclk)
7559 {
7560 damageovertimeclk = 0;
7561 }
7562
7563
2/2
✓ Branch 0 taken 18714663 times.
✓ Branch 1 taken 434 times.
18715097 if(lift_wpn)
7564 {
7565 434 auto oldid = lift_wpn->id;
7566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 434 times.
434 switch(lift_wpn->id)
7567 {
7568 case wLitBomb:
7569 case wBomb:
7570 case wLitSBomb:
7571 case wSBomb:
7572 if(lift_wpn->misc && get_bit(quest_rules,qr_HELD_BOMBS_EXPLODE)) //timed fuse
7573 {
7574 lift_wpn->limited_animate();
7575 if(lift_wpn->id != oldid)
7576 {
7577 lift_wpn->moveflags &= ~FLAG_OBEYS_GRAV;
7578 drop_liftwpn();
7579 goto heroanimate_skip_liftwpn;
7580 }
7581 ++lift_wpn->clk;
7582 }
7583 break;
7584 }
7585
1/2
✓ Branch 0 taken 434 times.
✗ Branch 1 not taken.
434 if(lift_wpn->dead>0)
7586 --lift_wpn->dead;
7587
7588
1/2
✓ Branch 0 taken 434 times.
✗ Branch 1 not taken.
434 if(lift_wpn->dead==0)
7589 {
7590 if(lift_wpn->death_spawnitem > -1)
7591 {
7592 item* itm = (new item(lift_wpn->x, lift_wpn->y, lift_wpn->z, lift_wpn->death_spawnitem, lift_wpn->death_item_pflags, 0));
7593 itm->fakez = lift_wpn->fakez;
7594 items.add(itm);
7595 }
7596 if(lift_wpn->death_spawndropset > -1)
7597 {
7598 auto itid = select_dropitem(lift_wpn->death_spawndropset);
7599 if(itid > -1)
7600 {
7601 item* itm = (new item(lift_wpn->x, lift_wpn->y, lift_wpn->z, itid, lift_wpn->death_item_pflags, 0));
7602 itm->fakez = lift_wpn->fakez;
7603 itm->from_dropset = lift_wpn->death_spawndropset;
7604 items.add(itm);
7605 }
7606 }
7607 switch(lift_wpn->death_sprite)
7608 {
7609 case -2: decorations.add(new dBushLeaves(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dBUSHLEAVES, 0, 0)); break;
7610 case -3: decorations.add(new dFlowerClippings(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dFLOWERCLIPPINGS, 0, 0)); break;
7611 case -4: decorations.add(new dGrassClippings(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dGRASSCLIPPINGS, 0, 0)); break;
7612 default:
7613 if(lift_wpn->death_sprite < 0) break;
7614 decorations.add(new comboSprite(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), 0, 0, lift_wpn->death_sprite));
7615 }
7616 if(lift_wpn->death_sfx > 0)
7617 sfx(lift_wpn->death_sfx, pan(int32_t(lift_wpn->x)));
7618 delete lift_wpn;
7619 lift_wpn = nullptr;
7620 }
7621 heroanimate_skip_liftwpn:;
7622 434 }
7623
7624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18715097 times.
18715097 if(cheats_execute_goto)
7625 {
7626 didpit=true;
7627 pitx=x;
7628 pity=y;
7629 dowarp(3,0);
7630 cheats_execute_goto=false;
7631 solid_update(false);
7632 return false;
7633 }
7634
7635
1/2
✓ Branch 0 taken 18715097 times.
✗ Branch 1 not taken.
18715097 if(cheats_execute_light)
7636 {
7637 naturaldark = !naturaldark;
7638 lighting(false, false, pal_litOVERRIDE);//Forcibly set permLit, overriding it's current setting
7639 cheats_execute_light = false;
7640 }
7641
7642
3/4
✓ Branch 0 taken 6419924 times.
✓ Branch 1 taken 12295173 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6419924 times.
18715097 if(action!=climbcovertop&&action!=climbcoverbottom)
7643 {
7644 6419924 climb_cover_x=-1000;
7645 6419924 climb_cover_y=-1000;
7646 6419924 }
7647
7648 18715097 handle_portal_collide(&mirror_portal);
7649
1/2
✓ Branch 0 taken 18715097 times.
✗ Branch 1 not taken.
18715097 portals.forEach([&](sprite& p)
7650 {
7651 return handle_portal_collide((portal*)&p);
7652 });
7653
7654
3/4
✓ Branch 0 taken 6416578 times.
✓ Branch 1 taken 12298519 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6416578 times.
18715097 if(z<=8&&fakez<=8)
7655 {
7656
2/2
✓ Branch 0 taken 42395 times.
✓ Branch 1 taken 6374183 times.
6416578 if (get_bit(quest_rules, qr_GRASS_SENSITIVE))
7657 {
7658 42395 bool g1 = isGrassType(COMBOTYPE(x+4,y+15)), g2 = isGrassType(COMBOTYPE(x+11,y+15)), g3 = isGrassType(COMBOTYPE(x+4,y+9)), g4 = isGrassType(COMBOTYPE(x+11,y+9));
7659
2/2
✓ Branch 0 taken 41531 times.
✓ Branch 1 taken 864 times.
42395 if(get_bit(quest_rules, qr_BUSHESONLAYERS1AND2))
7660 {
7661
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
864 g1 = g1 || isGrassType(COMBOTYPEL(1,x+4,y+15)) || isGrassType(COMBOTYPEL(2,x+4,y+15));
7662
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
864 g2 = g2 || isGrassType(COMBOTYPEL(1,x+11,y+15)) || isGrassType(COMBOTYPEL(2,x+11,y+15));
7663
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
864 g3 = g3 || isGrassType(COMBOTYPEL(1,x+4,y+9)) || isGrassType(COMBOTYPEL(2,x+4,y+9));
7664
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
864 g4 = g4 || isGrassType(COMBOTYPEL(1,x+11,y+9)) || isGrassType(COMBOTYPEL(2,x+11,y+9));
7665 864 }
7666
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 42395 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
42395 if(g1 && g2 && g3 && g4)
7667 {
7668 if(decorations.idCount(dTALLGRASS)==0)
7669 {
7670 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0));
7671 }
7672 int32_t thesfx = combobuf[MAPCOMBO(x+8,y+12)].attribytes[3];
7673 if (action==walking)
7674 sfx_no_repeat(thesfx,pan((int32_t)x));
7675 }
7676 42395 }
7677 else
7678 {
7679 6374183 bool g1 = isGrassType(COMBOTYPE(x,y+15)), g2 = isGrassType(COMBOTYPE(x+15,y+15));
7680
2/2
✓ Branch 0 taken 6347149 times.
✓ Branch 1 taken 27034 times.
6374183 if(get_bit(quest_rules, qr_BUSHESONLAYERS1AND2))
7681 {
7682
2/4
✓ Branch 0 taken 27034 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27034 times.
27034 g1 = g1 || isGrassType(COMBOTYPEL(1,x,y+15)) || isGrassType(COMBOTYPEL(2,x,y+15));
7683
2/4
✓ Branch 0 taken 27034 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27034 times.
27034 g2 = g2 || isGrassType(COMBOTYPEL(1,x+15,y+15)) || isGrassType(COMBOTYPEL(2,x+15,y+15));
7684 27034 }
7685
4/4
✓ Branch 0 taken 44398 times.
✓ Branch 1 taken 6329785 times.
✓ Branch 2 taken 5801 times.
✓ Branch 3 taken 38597 times.
6374183 if(g1 && g2)
7686 {
7687
2/2
✓ Branch 0 taken 38045 times.
✓ Branch 1 taken 552 times.
38597 if(decorations.idCount(dTALLGRASS)==0)
7688 {
7689
3/6
✓ Branch 0 taken 552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 552 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 552 times.
✗ Branch 5 not taken.
552 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0));
7690 552 }
7691 38597 int32_t thesfx = combobuf[MAPCOMBO(x+8,y+15)].attribytes[3];
7692
2/2
✓ Branch 0 taken 17055 times.
✓ Branch 1 taken 21542 times.
38597 if (action==walking )
7693 21542 sfx_no_repeat(thesfx,pan((int32_t)x));
7694 38597 }
7695 }
7696 6416578 }
7697
7698
2/2
✓ Branch 0 taken 12580127 times.
✓ Branch 1 taken 6134970 times.
18715097 if (get_bit(quest_rules, qr_SHALLOW_SENSITIVE))
7699 {
7700
19/26
✓ Branch 0 taken 281473 times.
✓ Branch 1 taken 12298654 times.
✓ Branch 2 taken 281473 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 280194 times.
✓ Branch 5 taken 1279 times.
✓ Branch 6 taken 280194 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 279554 times.
✓ Branch 9 taken 640 times.
✓ Branch 10 taken 279554 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 279554 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 279554 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 279344 times.
✓ Branch 17 taken 210 times.
✓ Branch 18 taken 279344 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 279311 times.
✓ Branch 21 taken 33 times.
✓ Branch 22 taken 279251 times.
✓ Branch 23 taken 60 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 279251 times.
12580127 if (z == 0 && fakez == 0 && action != swimming && action != isdiving && action != drowning && action!=lavadrowning && action!=sidedrowning && action!=rafting && action != falling && !IsSideSwim() && !(ladderx+laddery) && !pull_hero && !toogam)
7701 {
7702
2/2
✓ Branch 0 taken 256115 times.
✓ Branch 1 taken 23136 times.
304009 if (iswaterex(FFORCOMBO(x+11,y+15), currmap, currscr, -1, x+11,y+15, false, false, true, true)
7703
2/2
✓ Branch 0 taken 24758 times.
✓ Branch 1 taken 254493 times.
279251 && iswaterex(FFORCOMBO(x+4,y+15), currmap, currscr, -1, x+4,y+15, false, false, true, true)
7704
2/2
✓ Branch 0 taken 23876 times.
✓ Branch 1 taken 882 times.
24758 && iswaterex(FFORCOMBO(x+11,y+9), currmap, currscr, -1, x+11,y+9, false, false, true, true)
7705
2/2
✓ Branch 0 taken 23170 times.
✓ Branch 1 taken 706 times.
23876 && iswaterex(FFORCOMBO(x+4,y+9), currmap, currscr, -1, x+4,y+9, false, false, true, true))
7706 {
7707
2/2
✓ Branch 0 taken 22979 times.
✓ Branch 1 taken 157 times.
23136 if(decorations.idCount(dRIPPLES)==0)
7708 {
7709
3/6
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 157 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 157 times.
✗ Branch 5 not taken.
157 decorations.add(new dRipples(x, y, dRIPPLES, 0));
7710 157 }
7711 23136 int32_t watercheck = iswaterex(FFORCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, false, false, true, true);
7712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23136 times.
23136 if (combobuf[watercheck].usrflags&cflag2)
7713 {
7714 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
7715 {
7716 onpassivedmg = true;
7717 if (!damageovertimeclk)
7718 {
7719 int32_t curhp = game->get_life();
7720 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
7721 else game->set_life(vbound(game->get_life()+combobuf[watercheck].attributes[1]/10000L, 0, game->get_maxlife()));
7722 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
7723 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
7724 {
7725 hclk = 48;
7726 hitdir = -1;
7727 action = gothit; FFCore.setHeroAction(gothit);
7728 }
7729 }
7730 if (combobuf[watercheck].attribytes[1] > 0)
7731 {
7732 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
7733 else --damageovertimeclk;
7734 }
7735 else damageovertimeclk = 0;
7736 }
7737 else damageovertimeclk = 0;
7738 }
7739 23136 else damageovertimeclk = 0;
7740 23136 int32_t thesfx = combobuf[watercheck].attribytes[0];
7741
3/4
✓ Branch 0 taken 22806 times.
✓ Branch 1 taken 330 times.
✓ Branch 2 taken 22806 times.
✗ Branch 3 not taken.
23136 if (combobuf[watercheck].type != cSHALLOWWATER || !get_bit(quest_rules, qr_OLD_SHALLOW_SFX))
7742 {
7743 330 thesfx = combobuf[watercheck].attribytes[5];
7744 330 }
7745
2/2
✓ Branch 0 taken 12794 times.
✓ Branch 1 taken 10342 times.
23136 if (action==walking)
7746 10342 sfx_no_repeat(thesfx,pan((int32_t)x));
7747 23136 }
7748 279251 }
7749 12580127 }
7750 else
7751 {
7752
7/8
✓ Branch 0 taken 8860 times.
✓ Branch 1 taken 6126110 times.
✓ Branch 2 taken 8421 times.
✓ Branch 3 taken 439 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8421 times.
✓ Branch 6 taken 6126549 times.
✓ Branch 7 taken 8421 times.
6134970 if((COMBOTYPE(x,y+15)==cSHALLOWWATER)&&(COMBOTYPE(x+15,y+15)==cSHALLOWWATER) && z==0 && fakez==0)
7753 {
7754
2/2
✓ Branch 0 taken 8358 times.
✓ Branch 1 taken 63 times.
8421 if(decorations.idCount(dRIPPLES)==0)
7755 {
7756
3/6
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 63 times.
✗ Branch 5 not taken.
63 decorations.add(new dRipples(x, y, dRIPPLES, 0));
7757 63 }
7758 8421 int32_t watercheck = FFORCOMBO(x+7.5,y.getInt()+15);
7759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8421 times.
8421 if (combobuf[watercheck].usrflags&cflag2)
7760 {
7761 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
7762 {
7763 onpassivedmg = true;
7764 if (!damageovertimeclk)
7765 {
7766 int32_t curhp = game->get_life();
7767 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
7768 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
7769 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
7770 }
7771 if (combobuf[watercheck].attribytes[1] > 0)
7772 {
7773 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
7774 else --damageovertimeclk;
7775 }
7776 else damageovertimeclk = 0;
7777 }
7778 else damageovertimeclk = 0;
7779 }
7780 8421 else damageovertimeclk = 0;
7781 8421 int32_t thesfx = combobuf[watercheck].attribytes[0];
7782
2/2
✓ Branch 0 taken 4914 times.
✓ Branch 1 taken 3507 times.
8421 if (action==walking )
7783 3507 sfx_no_repeat(thesfx,pan((int32_t)x));
7784 8421 }
7785 }
7786
7787
2/2
✓ Branch 0 taken 18715058 times.
✓ Branch 1 taken 39 times.
18715097 if(stomping)
7788 39 stomping = false;
7789
7790
2/2
✓ Branch 0 taken 18714778 times.
✓ Branch 1 taken 319 times.
18715097 if(getOnSideviewLadder())
7791 {
7792
4/8
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 319 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 319 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 319 times.
319 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
7793 {
7794 setOnSideviewLadder(false);
7795 }
7796
2/8
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 319 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
319 else if(CANFORCEFACEUP)
7797 {
7798 setDir(up);
7799 }
7800 319 }
7801
7802
6/8
✓ Branch 0 taken 6410224 times.
✓ Branch 1 taken 12304873 times.
✓ Branch 2 taken 6409584 times.
✓ Branch 3 taken 640 times.
✓ Branch 4 taken 6409584 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6409584 times.
18715097 if(action!=inwind && action!=drowning && action!=lavadrowning && action!= sidedrowning)
7803 {
7804
2/2
✓ Branch 0 taken 6251778 times.
✓ Branch 1 taken 157806 times.
6409584 if(!get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
7805 {
7806 157806 checkchest(cCHEST);
7807 157806 checkchest(cLOCKEDCHEST);
7808 157806 checkchest(cBOSSCHEST);
7809 157806 }
7810
2/2
✓ Branch 0 taken 6381438 times.
✓ Branch 1 taken 28146 times.
6409584 if(!get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
7811 {
7812 28146 checkchest(cLOCKBLOCK);
7813 28146 checkchest(cBOSSLOCKBLOCK);
7814 28146 }
7815 6409584 }
7816 18715097 checksigns();
7817 18715097 checkgenpush();
7818
7819
4/4
✓ Branch 0 taken 6067224 times.
✓ Branch 1 taken 12647873 times.
✓ Branch 2 taken 2281 times.
✓ Branch 3 taken 6064943 times.
18715097 if(isStanding(true) && fall == 0)
7820 {
7821
1/2
✓ Branch 0 taken 6064943 times.
✗ Branch 1 not taken.
6064943 if(extra_jump_count > 0)
7822 extra_jump_count = 0;
7823 6064943 coyotetime = 0;
7824 6064943 }
7825
2/2
✓ Branch 0 taken 12297785 times.
✓ Branch 1 taken 352369 times.
12650154 else if(coyotetime < 65535)
7826 {
7827 352369 ++coyotetime;
7828 352369 }
7829
2/2
✓ Branch 0 taken 18705006 times.
✓ Branch 1 taken 10091 times.
18715097 if(can_use_item(itype_hoverboots,i_hoverboots))
7830 {
7831 10091 int32_t hoverid = current_item_id(itype_hoverboots);
7832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10091 times.
10091 if(!(itemsbuf[hoverid].flags & ITEM_FLAG1))
7833 {
7834
1/2
✓ Branch 0 taken 10091 times.
✗ Branch 1 not taken.
10091 if(hoverclk < 0) hoverclk = 0;
7835 10091 hoverflags &= ~HOV_OUT;
7836 10091 }
7837 10091 }
7838 18715097 bool platformfell2 = false;
7839 18715097 int32_t gravity3 = (zinit.gravity2/100);
7840 18715097 int32_t termv = (zinit.terminalv);
7841 18715097 int32_t rocs = getRocsPressed();
7842
2/2
✓ Branch 0 taken 1122 times.
✓ Branch 1 taken 18713975 times.
18715097 if (rocs != -1)
7843 {
7844 1122 itemdata const& itm = itemsbuf[rocs];
7845
1/2
✓ Branch 0 taken 1122 times.
✗ Branch 1 not taken.
1122 if (itm.flags & ITEM_FLAG2)
7846 {
7847 if ((!(itm.flags & ITEM_FLAG3) || fall < 0) &&
7848 (!(itm.flags & ITEM_FLAG4) || fall > 0)) gravity3 = itm.misc3;
7849 }
7850
1/2
✓ Branch 0 taken 1122 times.
✗ Branch 1 not taken.
1122 if (itm.flags & ITEM_FLAG5)
7851 {
7852 termv = itm.misc4;
7853 if (fall > termv) fall = termv;
7854 }
7855 1122 }
7856
2/2
✓ Branch 0 taken 261486 times.
✓ Branch 1 taken 18453611 times.
18715097 if(sideview_mode()) // Sideview gravity
7857 {
7858 //Handle falling through a platform
7859 261486 bool platformfell = false;
7860
4/4
✓ Branch 0 taken 133365 times.
✓ Branch 1 taken 128121 times.
✓ Branch 2 taken 133347 times.
✓ Branch 3 taken 18 times.
261486 if (on_sideview_solid_oldpos(x,y,old_x,old_y,true,3) && !on_sideview_solid_oldpos(x,y,old_x,old_y,false,3))
7861 {
7862
8/8
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 10 times.
✓ Branch 7 taken 8 times.
18 if (!(!on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && Down())) platformfell = true;
7863 18 y+=1; //Fall down a pixel instantly, through the platform.
7864
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 10 times.
18 if(fall < 0) fall = 0;
7865
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 8 times.
18 if(jumping < 0) jumping = 0;
7866 18 platformfell2 = true;
7867 18 }
7868 //Unless using old collision, run this check BEFORE moving Hero, to prevent clipping into the ceiling.
7869
2/2
✓ Branch 0 taken 10790 times.
✓ Branch 1 taken 250696 times.
261486 if(!get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON))
7870 {
7871
14/22
✓ Branch 0 taken 9809 times.
✓ Branch 1 taken 981 times.
✓ Branch 2 taken 981 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 981 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 981 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 981 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 980 times.
✓ Branch 12 taken 980 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 980 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 980 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 980 times.
✓ Branch 20 taken 10789 times.
✓ Branch 21 taken 1 times.
11771 if(fall < 0 && (_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE)
7872
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 980 times.
✓ Branch 2 taken 958 times.
✓ Branch 3 taken 22 times.
1002 || ((y+(fall/100)<=0) &&
7873 // Extra checks if Smart Screen Scrolling is enabled
7874
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
7875 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up)))))))
7876 {
7877 1 fall = jumping = 0; // Bumped his head
7878
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
7879 y -= y.getInt()%8; //fix coords
7880 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
7881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
7882 {
7883 1 checkdamagecombos(x+4, x+12, y-1, y-1);
7884 1 }
7885 1 }
7886 10790 }
7887 // Fall, unless on a ladder, sideview ladder, rafting, using the hookshot, drowning, sideswimming or cheating.
7888
8/14
✗ Branch 0 not taken.
✓ Branch 1 taken 261486 times.
✓ Branch 2 taken 261486 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 261486 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 261486 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 261486 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 261486 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 319 times.
✓ Branch 13 taken 261167 times.
261486 if(!(toogam && Up()) && !drownclk && action!=rafting && !IsSideSwim() && !pull_hero && !((ladderx || laddery) && fall>0) && !getOnSideviewLadder())
7889 {
7890
1/2
✓ Branch 0 taken 261167 times.
✗ Branch 1 not taken.
261167 int32_t ydiff = fall/(spins && fall<0 ? 200:100);
7891 //zprint2("ydif is: %d\n", ydiff);
7892 //zprint2("ydif is: %d\n", (int32_t)fall);
7893 261167 falling_oldy = y; // Stomp Boots-related variable
7894
8/8
✓ Branch 0 taken 48363 times.
✓ Branch 1 taken 212804 times.
✓ Branch 2 taken 48299 times.
✓ Branch 3 taken 64 times.
✓ Branch 4 taken 48362 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 261166 times.
✓ Branch 7 taken 1 times.
261167 if(fall > 0 && (checkSVLadderPlatform(x+4,y+ydiff+15)||checkSVLadderPlatform(x+12,y+ydiff+15)) && (((y.getInt()+ydiff+15)&0xF0)!=((y.getInt()+15)&0xF0)) && !platform_fallthrough())
7895 {
7896 1 ydiff -= (y.getInt()+ydiff)%16;
7897 1 }
7898
4/4
✓ Branch 0 taken 68744 times.
✓ Branch 1 taken 192423 times.
✓ Branch 2 taken 66794 times.
✓ Branch 3 taken 1950 times.
261167 if(ydiff && !get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
7899 {
7900
2/2
✓ Branch 0 taken 1097 times.
✓ Branch 1 taken 853 times.
1950 if(ydiff > 0)
7901 {
7902
2/2
✓ Branch 0 taken 1061 times.
✓ Branch 1 taken 2173 times.
3234 for(auto q = 0; q < ydiff; ++q)
7903 {
7904
2/2
✓ Branch 0 taken 2137 times.
✓ Branch 1 taken 36 times.
2173 if(on_sideview_solid_oldpos(x,y+q,old_x,old_y))
7905 {
7906 36 ydiff = q;
7907 36 break;
7908 }
7909 2137 }
7910 1097 }
7911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 853 times.
853 else if(ydiff < 0)
7912 {
7913
2/2
✓ Branch 0 taken 853 times.
✓ Branch 1 taken 1698 times.
2551 for(auto q = 0; q > ydiff; --q)
7914 {
7915
1/2
✓ Branch 0 taken 1698 times.
✗ Branch 1 not taken.
3396 if(_walkflag(x+4,y+(bigHitbox?0:8)+q-1,1)
7916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1698 times.
1698 || _walkflag(x+12,y+(bigHitbox?0:8)+q,1))
7917 {
7918 ydiff = q;
7919 break;
7920 }
7921 1698 }
7922 853 }
7923 1950 }
7924 261167 y+=ydiff;
7925 261167 hs_starty+=ydiff;
7926
7927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 261167 times.
261167 for(int32_t j=0; j<chainlinks.Count(); j++)
7928 {
7929 chainlinks.spr(j)->y+=ydiff;
7930 }
7931
7932
1/2
✓ Branch 0 taken 261167 times.
✗ Branch 1 not taken.
261167 if(Lwpns.idFirst(wHookshot)>-1)
7933 {
7934 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=ydiff;
7935 }
7936
7937
1/2
✓ Branch 0 taken 261167 times.
✗ Branch 1 not taken.
261167 if(Lwpns.idFirst(wHSHandle)>-1)
7938 {
7939 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=ydiff;
7940 }
7941 261167 }
7942
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 319 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
319 else if(IsSideSwim() && action != sidewaterhold1 && action != sidewaterhold2 && action != sideswimcasting && action != sideswimfreeze)
7943 {
7944 fall = hoverclk = jumping = 0;
7945 inair = false;
7946 hoverflags = 0;
7947 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
7948 {
7949 WalkflagInfo info;
7950 if (game->get_watergrav()<0)
7951 {
7952 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
7953 execute(info);
7954 }
7955 else
7956 {
7957 info = walkflag(x,y+15+2,2,down);
7958 execute(info);
7959 }
7960 if(!info.isUnwalkable() && (game->get_watergrav() > 0 || iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)-2), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false))) y+=(game->get_watergrav()/10000.0);
7961 }
7962 }
7963 // Stop hovering/falling if you land on something.
7964 261486 bool needFall = false;
7965
7/8
✓ Branch 0 taken 127634 times.
✓ Branch 1 taken 133852 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 261486 times.
✓ Branch 4 taken 134171 times.
✓ Branch 5 taken 127315 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 134158 times.
261486 if((on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder()) && !(pull_hero && dir==down) && action!=rafting && !platformfell2)
7966 {
7967 134158 stop_item_sfx(itype_hoverboots);
7968
1/2
✓ Branch 0 taken 124016 times.
✗ Branch 1 not taken.
258174 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE)
7969
2/2
✓ Branch 0 taken 126660 times.
✓ Branch 1 taken 7498 times.
134158 && !getOnSideviewLadder()
7970
3/4
✓ Branch 0 taken 126660 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124016 times.
✓ Branch 3 taken 2644 times.
126660 && (fall > 0 || get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON)))
7971 126660 y-=(int32_t)y%8; //fix position
7972 134158 fall = hoverclk = jumping = 0;
7973 134158 inair = false;
7974 134158 hoverflags = 0;
7975
7976
4/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 134150 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
134158 if(y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) // Landed on the bottommost screen.
7977 8 y = 160;
7978 134158 }
7979 // Stop hovering if you press down.
7980
3/6
✓ Branch 0 taken 127328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127328 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 127328 times.
✗ Branch 5 not taken.
127328 else if((hoverclk>0 || ladderx || laddery) && DrunkDown())
7981 {
7982 stop_item_sfx(itype_hoverboots);
7983 hoverclk = -hoverclk;
7984 reset_ladder();
7985 fall = gravity3;
7986 inair = false;
7987 }
7988
10/12
✓ Branch 0 taken 127328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3757 times.
✓ Branch 3 taken 123571 times.
✓ Branch 4 taken 1995 times.
✓ Branch 5 taken 1762 times.
✓ Branch 6 taken 1987 times.
✓ Branch 7 taken 8 times.
✓ Branch 8 taken 1987 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 281 times.
✓ Branch 11 taken 1706 times.
127328 else if (hoverclk < 1 && !inair && fall == 0 && !platformfell && !IsSideSwim() && justmoved <= 0)
7989 {
7990 1706 zfix my = y + 4;
7991 1706 needFall = true;
7992
2/2
✓ Branch 0 taken 642 times.
✓ Branch 1 taken 3185 times.
3827 for (zfix ty = y+1; ty < my; ++ty)
7993 {
7994 //if (on_sideview_solid_oldpos(x, ty,old_x,old_y, false, 1)) break;
7995
2/2
✓ Branch 0 taken 2121 times.
✓ Branch 1 taken 1064 times.
3185 if (on_sideview_solid_oldpos(x, ty,old_x,old_y, false, 0))
7996 {
7997 1064 y = ty;
7998
2/2
✓ Branch 0 taken 149 times.
✓ Branch 1 taken 915 times.
1064 if (check_new_slope(x, ty + 1, 16, 16, old_x, old_y, false) < 0)
7999 {
8000
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 15 times.
915 if(!slopeid)
8001 15 slopeid = get_new_slope(x, ty + 1, 16, 16, old_x, old_y).get_info().slope();
8002 915 onplatid = 5;
8003 915 }
8004 1064 needFall = false;
8005 1064 break;
8006 }
8007 2121 }
8008 1706 }
8009 125622 else needFall = true;
8010 // Continue falling.
8011
8012
4/4
✓ Branch 0 taken 254012 times.
✓ Branch 1 taken 7474 times.
✓ Branch 2 taken 135222 times.
✓ Branch 3 taken 118790 times.
261486 if(fall <= termv && needFall)
8013 {
8014 118790 inair = true;
8015
3/4
✓ Branch 0 taken 47129 times.
✓ Branch 1 taken 71661 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47129 times.
118790 if(fall != 0 || hoverclk>0)
8016 71661 jumping++;
8017
8018 // Bump head if: hit a solid combo from beneath, or hit a solid combo in the screen above this one.
8019
2/2
✓ Branch 0 taken 116656 times.
✓ Branch 1 taken 2134 times.
118790 if(get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON))
8020 {
8021
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 116656 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116656 times.
✓ Branch 4 taken 116065 times.
✓ Branch 5 taken 591 times.
233312 if((_walkflag(x+4,y-(bigHitbox?9:1),0,SWITCHBLOCK_STATE)
8022
4/4
✓ Branch 0 taken 111190 times.
✓ Branch 1 taken 5466 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 110284 times.
116656 || (y<=(bigHitbox?9:1) &&
8023 // Extra checks if Smart Screen Scrolling is enabled
8024
2/6
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 906 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
906 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8025 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8026
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
5466 && fall < 0)
8027 {
8028 591 fall = jumping = 0; // Bumped his head
8029
8030 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8031
2/2
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 110 times.
591 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8032 {
8033 110 checkdamagecombos(x+4, x+12, y-1, y-1);
8034 110 }
8035 591 }
8036 116656 }
8037 else
8038 {
8039
10/16
✗ Branch 0 not taken.
✓ Branch 1 taken 2134 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2134 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2134 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 2128 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2128 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2128 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2128 times.
✓ Branch 14 taken 2133 times.
✓ Branch 15 taken 1 times.
4268 if((_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE)
8040
3/4
✓ Branch 0 taken 2128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 2091 times.
2128 || ((y<=0) &&
8041 // Extra checks if Smart Screen Scrolling is enabled
8042
2/6
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
37 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8043 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8044
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 && fall < 0)
8045 {
8046 1 fall = jumping = 0; // Bumped his head
8047 1 y -= y.getInt()%8; //fix coords
8048 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8049
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8050 {
8051 1 checkdamagecombos(x+4, x+12, y-1, y-1);
8052 1 }
8053 1 }
8054 }
8055
8056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118790 times.
118790 if(hoverclk > 0)
8057 {
8058 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8059 {
8060 --hoverclk;
8061 }
8062
8063 if(!hoverclk && !ladderx && !laddery)
8064 {
8065 fall += gravity3;
8066 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8067 }
8068 }
8069
5/12
✓ Branch 0 taken 85980 times.
✓ Branch 1 taken 32810 times.
✓ Branch 2 taken 47827 times.
✓ Branch 3 taken 38153 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47827 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
118790 else if(fall+gravity3 > 0 && fall<=0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
8070 {
8071 int32_t itemid = current_item_id(itype_hoverboots);
8072 if(hoverclk < 0)
8073 hoverclk = -hoverclk;
8074 else
8075 {
8076 fall = jumping = 0;
8077 if(itemsbuf[itemid].misc1)
8078 hoverclk = itemsbuf[itemid].misc1;
8079 else
8080 {
8081 hoverclk = 1;
8082 hoverflags |= HOV_INF;
8083 }
8084
8085
8086 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
8087 }
8088 if(itemsbuf[itemid].wpn)
8089 decorations.add(new dHover(x, y, dHOVER, 0));
8090 }
8091
4/8
✓ Branch 0 taken 118790 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 118790 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 118790 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 118790 times.
118790 else if(!ladderx && !laddery && !getOnSideviewLadder() && !IsSideSwim())
8092 {
8093 118790 fall += gravity3;
8094
8095 118790 }
8096 118790 }
8097 261486 }
8098 else // Topdown gravity
8099 {
8100
4/4
✓ Branch 0 taken 12295174 times.
✓ Branch 1 taken 6158437 times.
✓ Branch 2 taken 848 times.
✓ Branch 3 taken 6157589 times.
18453611 if (!(moveflags & FLAG_NO_FAKE_Z)) fakez-=fakefall/(spins && fakefall>0 ? 200:100);
8101
4/4
✓ Branch 0 taken 12295174 times.
✓ Branch 1 taken 6158437 times.
✓ Branch 2 taken 848 times.
✓ Branch 3 taken 6157589 times.
18453611 if (!(moveflags & FLAG_NO_REAL_Z)) z-=fall/(spins && fall>0 ? 200:100);
8102
4/4
✓ Branch 0 taken 6154805 times.
✓ Branch 1 taken 12298806 times.
✓ Branch 2 taken 12302438 times.
✓ Branch 3 taken 18457243 times.
18453611 if(z>0||fakez>0)
8103 {
8104
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3632 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24601244 switch(action)
8105 {
8106 case swimming:
8107 {
8108 diveclk=0;
8109 action=walking; FFCore.setHeroAction(walking);
8110
8111 break;
8112 }
8113 case waterhold1:
8114 {
8115 action=landhold1; FFCore.setHeroAction(landhold1);
8116 break;
8117 }
8118
8119 case waterhold2:
8120 {
8121 action=landhold2; FFCore.setHeroAction(landhold2);
8122 break;
8123 }
8124
8125 default:
8126 3632 break;
8127 }
8128 3632 }
8129
8130
2/2
✓ Branch 0 taken 16982 times.
✓ Branch 1 taken 18460875 times.
18477857 for(int32_t j=0; j<chainlinks.Count(); j++)
8131 {
8132 16982 chainlinks.spr(j)->z=z;
8133 16982 chainlinks.spr(j)->fakez=fakez;
8134 16982 }
8135
8136
2/2
✓ Branch 0 taken 18456364 times.
✓ Branch 1 taken 4511 times.
18460875 if(Lwpns.idFirst(wHookshot)>-1)
8137 {
8138 4511 Lwpns.spr(Lwpns.idFirst(wHookshot))->z=z;
8139 4511 Lwpns.spr(Lwpns.idFirst(wHookshot))->fakez=fakez;
8140 4511 }
8141
8142
2/2
✓ Branch 0 taken 18456143 times.
✓ Branch 1 taken 4732 times.
18460875 if(Lwpns.idFirst(wHSHandle)>-1)
8143 {
8144 4732 Lwpns.spr(Lwpns.idFirst(wHSHandle))->z=z;
8145 4732 Lwpns.spr(Lwpns.idFirst(wHSHandle))->fakez=fakez;
8146 4732 }
8147
8148
3/4
✓ Branch 0 taken 6154805 times.
✓ Branch 1 taken 12306070 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6154805 times.
18460875 if(z<=0&&!(moveflags & FLAG_NO_REAL_Z))
8149 {
8150
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6154805 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6154805 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8151 {
8152
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 6154766 times.
6154805 if(fall > 0)
8153 {
8154
6/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✓ Branch 7 taken 6 times.
39 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8155 6 sfx(WAV_ZN1SPLASH,x.getInt());
8156
8157 39 stomping = true;
8158 39 }
8159 6154805 }
8160 6154805 z = fall = 0;
8161
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6154805 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6154805 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8162 {
8163 6154805 jumping = 0;
8164
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 6154551 times.
6154805 if(check_pitslide(true) == -1)
8165 {
8166 6154551 hoverclk = 0;
8167 6154551 hoverflags = 0;
8168 6154551 }
8169
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 237 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
254 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8170 {
8171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(!--hoverclk)
8172 {
8173 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8174 }
8175 17 }
8176 6154805 }
8177 6154805 }
8178
3/4
✓ Branch 0 taken 6158437 times.
✓ Branch 1 taken 12302438 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6158437 times.
18460875 if(fakez<=0&&!(moveflags & FLAG_NO_FAKE_Z))
8179 {
8180
3/4
✓ Branch 0 taken 3632 times.
✓ Branch 1 taken 6154805 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3632 times.
6158437 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8181 {
8182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6154805 times.
6154805 if(fakefall > 0)
8183 {
8184 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8185 sfx(WAV_ZN1SPLASH,x.getInt());
8186
8187 stomping = true;
8188 }
8189 6154805 }
8190 6158437 fakez = fakefall = 0;
8191
3/4
✓ Branch 0 taken 3632 times.
✓ Branch 1 taken 6154805 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3632 times.
6158437 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8192 {
8193 6154805 jumping = 0;
8194
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 6154551 times.
6154805 if(check_pitslide(true) == -1)
8195 {
8196 6154551 hoverclk = 0;
8197 6154551 hoverflags = 0;
8198 6154551 }
8199
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 237 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
254 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8200 {
8201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(!--hoverclk)
8202 {
8203 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8204 }
8205 17 }
8206 6154805 }
8207 6158437 }
8208
8/10
✓ Branch 0 taken 6158414 times.
✓ Branch 1 taken 12302461 times.
✓ Branch 2 taken 6158414 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6151219 times.
✓ Branch 5 taken 7195 times.
✓ Branch 6 taken 6154828 times.
✓ Branch 7 taken 6154828 times.
✓ Branch 8 taken 6154828 times.
✗ Branch 9 not taken.
18460875 if(fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z>0 || fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)
8209 {
8210
4/6
✓ Branch 0 taken 2725 times.
✓ Branch 1 taken 884 times.
✓ Branch 2 taken 2725 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2725 times.
12306047 if(fall != 0 || fakefall != 0 || hoverclk>0)
8211 884 jumping++;
8212
8213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3609 times.
3609 if(hoverclk > 0)
8214 {
8215 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8216 {
8217 --hoverclk;
8218 }
8219
8220 if(!hoverclk)
8221 {
8222 if (fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += gravity3;
8223 if (fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += gravity3;
8224 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8225 }
8226 }
8227
9/16
✓ Branch 0 taken 3239 times.
✓ Branch 1 taken 370 times.
✓ Branch 2 taken 2735 times.
✓ Branch 3 taken 504 times.
✓ Branch 4 taken 2735 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 874 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 874 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 874 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 3609 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
3609 else if(((fall+(int32_t)(zinit.gravity2 / 100) > 0 && fall<=0 && !(moveflags & FLAG_NO_REAL_Z) && z > 0) || (fakefall+gravity3 > 0 && fakefall<=0 && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)) && can_use_item(itype_hoverboots,i_hoverboots) && !(hoverflags & HOV_OUT))
8228 {
8229 if(hoverclk < 0)
8230 hoverclk = -hoverclk;
8231 else
8232 {
8233 fall = 0;
8234 fakefall = 0;
8235 int32_t itemid = current_item_id(itype_hoverboots);
8236 if(itemsbuf[itemid].misc1)
8237 hoverclk = itemsbuf[itemid].misc1;
8238 else
8239 {
8240 hoverclk = 1;
8241 hoverflags |= HOV_INF;
8242 }
8243 sfx(itemsbuf[current_item_id(itype_hoverboots)].usesound,pan(x.getInt()));
8244 }
8245 decorations.add(new dHover(x, y, dHOVER, 0));
8246 }
8247 else
8248 {
8249
3/6
✓ Branch 0 taken 3609 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3609 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3609 times.
3609 if (fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += gravity3;
8250
3/6
✓ Branch 0 taken 3609 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3609 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3609 times.
✗ Branch 5 not taken.
3609 if (fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += gravity3;
8251 }
8252 3609 }
8253
1/2
✓ Branch 0 taken 6158437 times.
✗ Branch 1 not taken.
6158437 if (fakez<0) fakez = 0;
8254
1/2
✓ Branch 0 taken 6158437 times.
✗ Branch 1 not taken.
6158437 if (z<0) z = 0;
8255 }
8256
8257
1/2
✓ Branch 0 taken 6419923 times.
✗ Branch 1 not taken.
6419923 if(drunkclk)
8258 {
8259 --drunkclk;
8260 }
8261
8262
1/2
✓ Branch 0 taken 6419923 times.
✗ Branch 1 not taken.
6419923 if(lstunclock > 0)
8263 {
8264 // also cancel Hero's attack
8265 attackclk = 0;
8266
8267 if( FFCore.getHeroAction() != stunned )
8268 {
8269 tempaction=action; //update so future checks won't do this
8270 //action=freeze; //setting this makes the player invincible while stunned -V
8271 FFCore.setHeroAction(stunned);
8272 }
8273 --lstunclock;
8274 }
8275 //if the stun action is still set in FFCore, but he isn't stunned, then the timer reached 0
8276 //, so we unfreeze him here, and return him to the action that he had when he was stunned.
8277
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6419923 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6419923 if ( FFCore.getHeroAction() == stunned && !lstunclock )
8278 {
8279 action=tempaction; FFCore.setHeroAction(tempaction);
8280 //zprint("Unfreezing hero to action: %d\n", (int32_t)tempaction);
8281 //action=none; FFCore.setHeroAction(none);
8282 }
8283
8284
1/2
✓ Branch 0 taken 6419923 times.
✗ Branch 1 not taken.
6419923 if( lbunnyclock > 0 )
8285 {
8286 --lbunnyclock;
8287 }
8288
2/2
✓ Branch 0 taken 1925 times.
✓ Branch 1 taken 6417998 times.
6419923 if(DMaps[currdmap].flags&dmfBUNNYIFNOPEARL)
8289 {
8290 1925 int32_t itemid = current_item_id(itype_pearl);
8291
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 1802 times.
1925 if(itemid > -1)
8292 {
8293
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 1 times.
123 if(lbunnyclock == -1) //cure dmap-caused bunny effect
8294 1 lbunnyclock = 0;
8295 123 }
8296
2/2
✓ Branch 0 taken 1801 times.
✓ Branch 1 taken 1 times.
1802 else if(lbunnyclock > -1) //No pearl, force into bunny mode
8297 {
8298 1 lbunnyclock = -1;
8299 1 }
8300 1925 }
8301
1/2
✓ Branch 0 taken 6417998 times.
✗ Branch 1 not taken.
6417998 else if(lbunnyclock == -1) //dmap-caused bunny effect
8302 {
8303 lbunnyclock = 0;
8304 }
8305
8306
13/18
✓ Branch 0 taken 6412088 times.
✓ Branch 1 taken 7835 times.
✓ Branch 2 taken 5699850 times.
✓ Branch 3 taken 712238 times.
✓ Branch 4 taken 5699850 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5699850 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1206 times.
✓ Branch 9 taken 5698644 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1206 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 5698041 times.
✓ Branch 15 taken 1809 times.
✓ Branch 16 taken 45294 times.
✓ Branch 17 taken 5652153 times.
6419923 if(!is_on_conveyor && !(diagonalMovement||NO_GRIDLOCK) && (fall==0 || fakefall==0 || z>0 || fakez>0) && charging==0 && spins<=5
8307
2/2
✓ Branch 0 taken 5697447 times.
✓ Branch 1 taken 594 times.
5698041 && action != gothit)
8308 {
8309
2/3
✓ Branch 0 taken 2533843 times.
✓ Branch 1 taken 3118310 times.
✗ Branch 2 not taken.
5652153 switch(dir)
8310 {
8311 case up:
8312 case down:
8313 2533843 x=(x.getInt()+4)&0xFFF8;
8314 2533843 break;
8315
8316 case left:
8317 case right:
8318 3118310 y=(y.getInt()+4)&0xFFF8;
8319 3118310 break;
8320 }
8321 5652153 }
8322
8323
4/4
✓ Branch 0 taken 116936 times.
✓ Branch 1 taken 6302987 times.
✓ Branch 2 taken 77419 times.
✓ Branch 3 taken 39517 times.
6419923 if((watch==true) && clockclk)
8324 {
8325 39517 --clockclk;
8326
8327
2/2
✓ Branch 0 taken 39410 times.
✓ Branch 1 taken 107 times.
39517 if(!clockclk)
8328 {
8329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(cheat_superman==false)
8330 {
8331 107 setClock(false);
8332 107 }
8333
8334 107 watch=false;
8335
8336
2/2
✓ Branch 0 taken 54784 times.
✓ Branch 1 taken 107 times.
54891 for(int32_t i=0; i<eMAXGUYS; i++)
8337 {
8338
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 54784 times.
54790 for(int32_t zoras=0; zoras<clock_zoras[i]; zoras++)
8339 {
8340 6 addenemy(0,0,i,0);
8341 6 }
8342 54784 }
8343 107 }
8344 39517 }
8345
8346
3/4
✓ Branch 0 taken 6415191 times.
✓ Branch 1 taken 4732 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6415191 times.
6419923 if(hookshot_frozen || switch_hooked)
8347 {
8348
3/4
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 4511 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 221 times.
4732 if(hookshot_used || switch_hooked)
8349 {
8350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4511 times.
4511 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
8351 4511 else {action=freeze; FFCore.setHeroAction(freeze);} //could be LA_HOOKSHOT for FFCore. -Z
8352
8353
3/4
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 623 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3888 times.
4511 if(pull_hero || switch_hooked)
8354 {
8355
3/4
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 563 times.
623 if(hs_switcher || switch_hooked)
8356 {
8357 60 hs_fix = false;
8358
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(switchhookclk)
8359 {
8360 60 --switchhookclk;
8361
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 59 times.
60 if(switchhookclk==switchhookmaxtime/2) //Perform swaps
8362 {
8363
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 if(switchhook_cost_item > -1 && !checkmagiccost(switchhook_cost_item))
8364 reset_hookshot();
8365 else
8366 {
8367 1 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
8368 1 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
8369
8370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(hooked_combopos > -1) //Switching combos
8371 {
8372 uint16_t targpos = hooked_combopos, plpos = COMBOPOS(x+8,y+8);
8373 if(targpos < 176 && plpos < 176 && hooked_layerbits)
8374 {
8375 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
8376 for(int q = max_layer; q > -1; --q)
8377 {
8378 if(!(hooked_layerbits & (1<<q)))
8379 continue; //non-switching layer
8380 mapscr* scr = FFCore.tempScreens[q];
8381 newcombo const& cmb = combobuf[scr->data[targpos]];
8382 int32_t srcfl = scr->sflag[targpos];
8383 newcombo const& comb2 = combobuf[scr->data[plpos]];
8384 int32_t c = scr->data[plpos], cs = scr->cset[plpos], fl = scr->sflag[plpos];
8385 //{Check push status
8386 bool isFakePush = false;
8387 if(cmb.type == cSWITCHHOOK)
8388 {
8389 if(cmb.usrflags&cflag7) //counts as 'pushblock'
8390 isFakePush = true;
8391 }
8392 bool isPush = isFakePush;
8393 if(!isPush) switch(srcfl)
8394 {
8395 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8396 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8397 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8398 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8399 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8400 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8401 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8402 isPush = true;
8403 }
8404 if(!isPush) switch(cmb.flag)
8405 {
8406 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8407 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8408 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8409 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8410 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8411 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8412 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8413 isPush = true;
8414 }
8415 if(srcfl==mfPUSHED) isPush = false;
8416 //}
8417 if(cmb.type == cSWITCHHOOK) //custom flags and such
8418 {
8419 if(cmb.usrflags&cflag3) //Breaks on swap
8420 {
8421 int32_t it = -1;
8422 int32_t thedropset = -1;
8423 if(cmb.usrflags&cflag4) //drop item
8424 {
8425 if(cmb.usrflags&cflag5)
8426 it = cmb.attribytes[2];
8427 else
8428 {
8429 it = select_dropitem(cmb.attribytes[2]);
8430 thedropset = cmb.attribytes[2];
8431 }
8432 }
8433
8434 breakable* br = new breakable(x, y, zfix(0),
8435 cmb, scr->cset[targpos], it, thedropset, cmb.attribytes[2],
8436 cmb.attribytes[1] ? -1 : 0, cmb.attribytes[1], switchhookclk);
8437 br->switch_hooked = true;
8438 decorations.add(br);
8439 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8440 hooked_undercombos[q] = -1;
8441
8442 if(cmb.usrflags&cflag6)
8443 {
8444 scr->data[targpos]++;
8445 }
8446 else
8447 {
8448 scr->data[targpos] = scr->undercombo;
8449 scr->cset[targpos] = scr->undercset;
8450 if(cmb.usrflags&cflag2)
8451 scr->sflag[targpos] = 0;
8452 }
8453 }
8454 else if(isPush)
8455 {
8456 //Simulate a block clicking into place
8457 movingblock mtemp;
8458 mtemp.clear();
8459 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
8460 mtemp.dir = getPushDir(scr->sflag[targpos]);
8461 if(mtemp.dir < 0)
8462 mtemp.dir = getPushDir(cmb.flag);
8463 mtemp.clk = 1;
8464 mtemp.force_many = isFakePush;
8465 mtemp.no_icy = true;
8466 mtemp.animate(0);
8467 if((mtemp.bhole || mtemp.trigger)
8468 && (fl == mfBLOCKTRIGGER || fl == mfBLOCKHOLE
8469 || comb2.flag == mfBLOCKTRIGGER
8470 || comb2.flag == mfBLOCKHOLE))
8471 {
8472 scr->data[targpos] = scr->undercombo;
8473 scr->cset[targpos] = scr->undercset;
8474 scr->sflag[targpos] = 0;
8475 }
8476 else
8477 {
8478 scr->data[targpos] = c;
8479 scr->cset[targpos] = cs;
8480 if(cmb.usrflags&cflag2)
8481 scr->sflag[targpos] = fl;
8482 else
8483 scr->sflag[targpos] = 0;
8484 }
8485 }
8486 else
8487 {
8488 scr->data[plpos] = scr->data[targpos];
8489 scr->cset[plpos] = scr->cset[targpos];
8490 if(cmb.usrflags&cflag2)
8491 scr->sflag[plpos] = scr->sflag[targpos];
8492 scr->data[targpos] = c;
8493 scr->cset[targpos] = cs;
8494 if(cmb.usrflags&cflag2)
8495 scr->sflag[targpos] = fl;
8496 }
8497 }
8498 else if(isCuttableType(cmb.type)) //Break and drop effects
8499 {
8500 int32_t breakcs = scr->cset[targpos];
8501 if(isCuttableNextType(cmb.type)) //next instead of undercmb
8502 {
8503 scr->data[targpos]++;
8504 }
8505 else
8506 {
8507 scr->data[targpos] = scr->undercombo;
8508 scr->cset[targpos] = scr->undercset;
8509 scr->sflag[targpos] = 0;
8510 }
8511
8512 int32_t it = -1;
8513 int32_t thedropset = -1;
8514 if(isCuttableItemType(cmb.type)) //Drop an item
8515 {
8516 if ( (cmb.usrflags&cflag2) )
8517 {
8518 if(cmb.usrflags&cflag11)
8519 it = cmb.attribytes[1];
8520 else
8521 {
8522 it = select_dropitem(cmb.attribytes[1]);
8523 thedropset = cmb.attribytes[1];
8524 }
8525 }
8526 else
8527 {
8528 it = select_dropitem(12);
8529 thedropset = 12;
8530 }
8531 }
8532
8533 byte breaksfx = 0;
8534 if(get_bit(quest_rules,qr_MORESOUNDS)) //SFX
8535 {
8536 if (cmb.usrflags&cflag3)
8537 {
8538 breaksfx = cmb.attribytes[2];
8539 }
8540 else if(isBushType(cmb.type)
8541 || isFlowersType(cmb.type)
8542 || isGrassType(cmb.type))
8543 {
8544 breaksfx = QMisc.miscsfx[sfxBUSHGRASS];
8545 }
8546 }
8547
8548 //Clipping sprite
8549 int16_t decotype = (cmb.usrflags & cflag1) ?
8550 ((cmb.usrflags & cflag10)
8551 ? (cmb.attribytes[0])
8552 : (-1))
8553 : (0);
8554 if(decotype > 3) decotype = 0;
8555 if(!decotype)
8556 decotype = (isBushType(cmb.type) ? 1
8557 : (isFlowersType(cmb.type) ? 2
8558 : (isGrassType(cmb.type) ? 3
8559 : ((cmb.usrflags & cflag1) ? -1
8560 : -2))));
8561
8562 breakable* br = new breakable(x, y, zfix(0),
8563 cmb, breakcs, it, thedropset, breaksfx,
8564 decotype, cmb.attribytes[0], switchhookclk);
8565 br->switch_hooked = true;
8566 decorations.add(br);
8567 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8568 hooked_undercombos[q] = -1;
8569 }
8570 else //Unknown type, just swap combos.
8571 {
8572 if(isPush)
8573 {
8574 //Simulate a block clicking into place
8575 movingblock mtemp;
8576 mtemp.clear();
8577 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
8578 mtemp.dir = getPushDir(scr->sflag[targpos]);
8579 if(mtemp.dir < 0)
8580 mtemp.dir = getPushDir(cmb.flag);
8581 mtemp.clk = 1;
8582 mtemp.animate(0);
8583 if(mtemp.bhole || mtemp.trigger)
8584 {
8585 scr->data[targpos] = scr->undercombo;
8586 scr->cset[targpos] = scr->undercset;
8587 scr->sflag[targpos] = 0;
8588 }
8589 else
8590 {
8591 scr->data[targpos] = c;
8592 scr->cset[targpos] = cs;
8593 scr->sflag[targpos] = 0;
8594 }
8595 }
8596 else
8597 {
8598 scr->data[plpos] = scr->data[targpos];
8599 scr->cset[plpos] = scr->cset[targpos];
8600 scr->data[targpos] = c;
8601 scr->cset[targpos] = cs;
8602 }
8603 }
8604 }
8605 if(switchhook_cost_item > -1)
8606 paymagiccost(switchhook_cost_item);
8607 zfix tx = x, ty = y;
8608 //Position the player at the combo
8609 x = COMBOX(targpos);
8610 y = COMBOY(targpos);
8611 dir = oppositeDir[dir];
8612 if(w && hw)
8613 {
8614 //Calculate chain shift
8615 zfix dx = (x-tx);
8616 zfix dy = (y-ty);
8617 if(w->dir < 4)
8618 {
8619 if(w->dir & 2)
8620 dx = 0;
8621 else dy = 0;
8622 }
8623 //Position the hook head at the handle
8624 w->x = hw->x + dx;
8625 w->y = hw->y + dy;
8626 w->dir = oppositeDir[w->dir];
8627 w->doAutoRotate(true);
8628 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
8629 w->flip ^= hflip;
8630 //Position the handle appropriately
8631 hw->x = x-(hw->x-tx);
8632 hw->y = y-(hw->y-ty);
8633 hw->dir = oppositeDir[hw->dir];
8634 hw->doAutoRotate(true);
8635 hw->flip ^= hflip;
8636 //Move chains
8637 for(int32_t j=0; j<chainlinks.Count(); j++)
8638 {
8639 chainlinks.spr(j)->x += dx;
8640 chainlinks.spr(j)->y += dy;
8641 }
8642 }
8643 hooked_combopos = plpos; //flip positions
8644 }
8645 else reset_hookshot();
8646 }
8647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(switching_object) //Switching an object
8648 {
8649
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(switchhook_cost_item > -1)
8650 paymagiccost(switchhook_cost_item);
8651 1 zfix tx = x, ty = y;
8652 //Position the player at the object
8653 1 x = switching_object->x;
8654 1 y = switching_object->y;
8655 1 dir = oppositeDir[dir];
8656 //Position the object at the player
8657 1 switching_object->x = tx;
8658 1 switching_object->y = ty;
8659
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(switching_object->dir == dir || switching_object->dir == oppositeDir[dir])
8660 switching_object->dir = oppositeDir[switching_object->dir];
8661 1 solid_update(false);
8662 1 switching_object->solid_update(false);
8663
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(item* it = dynamic_cast<item*>(switching_object))
8664 {
8665 if(itemsbuf[it->id].family == itype_fairy && itemsbuf[it->id].misc3)
8666 {
8667 movefairynew2(it->x, it->y, *it);
8668 }
8669 }
8670
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(w && hw) //!TODO No fucking clue if diagonals work
8671 {
8672 //Calculate chain shift
8673 1 zfix dx = (x-tx);
8674 1 zfix dy = (y-ty);
8675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(w->dir < 4)
8676 {
8677
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(w->dir & 2)
8678 1 dx = 0;
8679 else dy = 0;
8680 1 }
8681 //Position the hook head at the handle
8682 1 w->x = hw->x + dx;
8683 1 w->y = hw->y + dy;
8684 1 w->dir = oppositeDir[w->dir];
8685 1 w->doAutoRotate(true);
8686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
8687 1 w->flip ^= hflip;
8688 1 w->solid_update(false);
8689 //Position the handle appropriately
8690 1 hw->x = x-(hw->x-tx);
8691 1 hw->y = y-(hw->y-ty);
8692 1 hw->dir = oppositeDir[hw->dir];
8693 1 hw->doAutoRotate(true);
8694 1 hw->flip ^= hflip;
8695 1 hw->solid_update(false);
8696 //Move chains
8697
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for(int32_t j=0; j<chainlinks.Count(); j++)
8698 {
8699 5 chainlinks.spr(j)->x += dx;
8700 5 chainlinks.spr(j)->y += dy;
8701 5 }
8702 1 }
8703 1 }
8704 }
8705 1 }
8706
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 1 times.
59 else if(!switchhookclk)
8707 {
8708 1 reset_hookshot();
8709 1 }
8710 60 }
8711 else reset_hookshot();
8712 60 }
8713 else
8714 {
8715 sprite *t;
8716 int32_t i;
8717
8718
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 579 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 563 times.
579 for(i=0; i<Lwpns.Count() && (Lwpns.spr(i)->id!=wHSHandle); i++)
8719 {
8720 /* do nothing */
8721 16 }
8722
8723 563 t = Lwpns.spr(i);
8724
8725
2/2
✓ Branch 0 taken 1142 times.
✓ Branch 1 taken 563 times.
1705 for(i=0; i<Lwpns.Count(); i++)
8726 {
8727 1142 sprite *s = Lwpns.spr(i);
8728
8729
2/2
✓ Branch 0 taken 579 times.
✓ Branch 1 taken 563 times.
1142 if(s->id==wHookshot)
8730 {
8731
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 500 times.
563 if (abs((s->y) - y) >= 1)
8732 {
8733
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 38 times.
63 if((s->y)>y)
8734 {
8735 38 y+=4;
8736
8737
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(Lwpns.idFirst(wHSHandle)!=-1)
8738 {
8739 38 t->y+=4;
8740 38 }
8741
8742 38 hs_starty+=4;
8743 38 }
8744
8745
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 25 times.
63 if((s->y)<y)
8746 {
8747 25 y-=4;
8748
8749
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(Lwpns.idFirst(wHSHandle)!=-1)
8750 {
8751 25 t->y-=4;
8752 25 }
8753
8754 25 hs_starty-=4;
8755 25 }
8756 63 }
8757 else
8758 {
8759 500 y = (s->y);
8760 }
8761
2/2
✓ Branch 0 taken 500 times.
✓ Branch 1 taken 63 times.
563 if (abs((s->x) - x) >= 1)
8762 {
8763
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 338 times.
500 if((s->x)>x)
8764 {
8765 338 x+=4;
8766
8767
1/2
✓ Branch 0 taken 338 times.
✗ Branch 1 not taken.
338 if(Lwpns.idFirst(wHSHandle)!=-1)
8768 {
8769 338 t->x+=4;
8770 338 }
8771
8772 338 hs_startx+=4;
8773 338 }
8774
8775
2/2
✓ Branch 0 taken 338 times.
✓ Branch 1 taken 162 times.
500 if((s->x)<x)
8776 {
8777 162 x-=4;
8778
8779
1/2
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
162 if(Lwpns.idFirst(wHSHandle)!=-1)
8780 {
8781 162 t->x-=4;
8782 162 }
8783
8784 162 hs_startx-=4;
8785 162 }
8786 500 }
8787 else
8788 {
8789 63 x = (s->x);
8790 }
8791 563 }
8792 1142 }
8793 }
8794 623 }
8795 4511 }
8796 else
8797 {
8798 221 Lwpns.del(Lwpns.idFirst(wHSHandle));
8799 221 reset_hookshot();
8800 }
8801
8802
1/2
✓ Branch 0 taken 4732 times.
✗ Branch 1 not taken.
4732 if(hs_fix)
8803 {
8804 if(dir==up)
8805 {
8806 y=int32_t(y+7)&0xF0;
8807 }
8808
8809 if(dir==down)
8810 {
8811 y=int32_t(y+7)&0xF0;
8812 }
8813
8814 if(dir==left)
8815 {
8816 x=int32_t(x+7)&0xF0;
8817 }
8818
8819 if(dir==right)
8820 {
8821 x=int32_t(x+7)&0xF0;
8822 }
8823
8824 hs_fix=false;
8825 }
8826
8827 4732 }
8828
8829
2/2
✓ Branch 0 taken 370914 times.
✓ Branch 1 taken 6049009 times.
6419923 if(!get_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP))
8830 {
8831
2/2
✓ Branch 0 taken 3382 times.
✓ Branch 1 taken 6045627 times.
6049009 if(DrunkrLbtn())
8832 3382 selectNextBWpn(SEL_LEFT);
8833
2/2
✓ Branch 0 taken 6041917 times.
✓ Branch 1 taken 3710 times.
6045627 else if(DrunkrRbtn())
8834 3710 selectNextBWpn(SEL_RIGHT);
8835 6049009 }
8836
4/4
✓ Branch 0 taken 381005 times.
✓ Branch 1 taken 6038918 times.
✓ Branch 2 taken 370350 times.
✓ Branch 3 taken 10655 times.
6419923 if (get_bit(quest_rules, qr_SELECTAWPN) && get_bit(quest_rules, qr_USE_EX1_EX2_INVENTORYSWAP))
8837 {
8838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10655 times.
10655 if (rEx3btn())
8839 selectNextAWpn(SEL_LEFT);
8840
2/2
✓ Branch 0 taken 10654 times.
✓ Branch 1 taken 1 times.
10655 else if (rEx4btn())
8841 1 selectNextAWpn(SEL_RIGHT);
8842 10655 }
8843
8844
2/2
✓ Branch 0 taken 6419643 times.
✓ Branch 1 taken 280 times.
6419923 if(rPbtn())
8845 {
8846
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 277 times.
280 if( !FFCore.runOnMapScriptEngine() ) //OnMap script replaces the 'onViewMap()' call
8847 277 onViewMap();
8848 280 }
8849
2/2
✓ Branch 0 taken 2708324 times.
✓ Branch 1 taken 6419923 times.
9128247 for(int32_t i=0; i<Lwpns.Count(); i++)
8850 {
8851 2708324 weapon *w = ((weapon*)Lwpns.spr(i));
8852
8853
6/6
✓ Branch 0 taken 2687411 times.
✓ Branch 1 taken 20913 times.
✓ Branch 2 taken 2394388 times.
✓ Branch 3 taken 293023 times.
✓ Branch 4 taken 73 times.
✓ Branch 5 taken 2394315 times.
2708324 if(w->id == wArrow || w->id == wBrang || w->id == wCByrna)
8854 314009 addsparkle(i);
8855 2708324 }
8856
8857
1/2
✓ Branch 0 taken 6419923 times.
✗ Branch 1 not taken.
6419923 if(Lwpns.idCount(wPhantom))
8858 {
8859 addsparkle2(pDIVINEFIREROCKET,pDIVINEFIREROCKETTRAIL);
8860 addsparkle2(pDIVINEFIREROCKETRETURN,pDIVINEFIREROCKETTRAILRETURN);
8861 addsparkle2(pDIVINEPROTECTIONROCKET1,pDIVINEPROTECTIONROCKETTRAIL1);
8862 addsparkle2(pDIVINEPROTECTIONROCKET2,pDIVINEPROTECTIONROCKETTRAIL2);
8863 addsparkle2(pDIVINEPROTECTIONROCKETRETURN1,pDIVINEPROTECTIONROCKETTRAILRETURN1);
8864 addsparkle2(pDIVINEPROTECTIONROCKETRETURN2,pDIVINEPROTECTIONROCKETTRAILRETURN2);
8865 }
8866
8867 // Pay magic cost for Byrna beams
8868
8869 //Byrna needs a secondary timer, for 254+, as do all items that reduce MP on a per-frae basis. Essentially, we will do % divisor == 0 for that. -Z
8870
2/2
✓ Branch 0 taken 6419850 times.
✓ Branch 1 taken 73 times.
6419923 if(Lwpns.idCount(wCByrna))
8871 {
8872 73 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
8873 73 int32_t itemid = ew->parentitem;
8874
8875
2/4
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73 times.
73 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
8876 {
8877 for(int32_t i=0; i<Lwpns.Count(); i++)
8878 {
8879 weapon *w = ((weapon*)Lwpns.spr(i));
8880
8881 if(w->id==wCByrna)
8882 {
8883 w->dead=1;
8884 }
8885
8886 }
8887 //kill the sound effect for the orbits -Z 14FEB2019
8888 stop_sfx(itemsbuf[itemid].usesound);
8889 }
8890 73 else paymagiccost(itemid);
8891 73 }
8892
8893
3/4
✓ Branch 0 taken 6416291 times.
✓ Branch 1 taken 3632 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6416291 times.
6419923 if(z==0&&fakez==0)
8894 {
8895 6416291 switchblock_z = 0;
8896
1/2
✓ Branch 0 taken 6416291 times.
✗ Branch 1 not taken.
6416291 if(switchblock_offset)
8897 {
8898 switchblock_offset=false;
8899 yofs += 8;
8900 }
8901 6416291 }
8902
2/2
✓ Branch 0 taken 261486 times.
✓ Branch 1 taken 6158437 times.
6419923 if(!isSideViewHero())
8903 {
8904 6158437 int32_t tx = x.getInt()+8,
8905 6158437 ty = y.getInt()+8;//(bigHitbox?8:12);
8906
4/4
✓ Branch 0 taken 6158190 times.
✓ Branch 1 taken 247 times.
✓ Branch 2 taken 214 times.
✓ Branch 3 taken 6157976 times.
6158437 if(!(unsigned(ty)>175 || unsigned(tx) > 255))
8907 {
8908
2/2
✓ Branch 0 taken 6157976 times.
✓ Branch 1 taken 18473928 times.
24631904 for(int32_t q = 0; q < 3; ++q)
8909 {
8910
4/4
✓ Branch 0 taken 12315952 times.
✓ Branch 1 taken 6157976 times.
✓ Branch 2 taken 10705057 times.
✓ Branch 3 taken 1610895 times.
18473928 if(q && !tmpscr2[q-1].valid) continue;
8911 7768871 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[COMBOPOS(tx,ty)]];
8912
3/4
✓ Branch 0 taken 967 times.
✓ Branch 1 taken 7767904 times.
✓ Branch 2 taken 967 times.
✗ Branch 3 not taken.
7768871 if(cmb.type != cCSWITCHBLOCK || !(cmb.usrflags&cflag9)) continue;
8913 int32_t b = 1;
8914 if(tx&8) b <<= 2;
8915 if(ty&8) b <<= 1;
8916 b |= (b<<4); //check equivalent effect flag too
8917 if((cmb.walk&b)==b) //solid and effecting
8918 {
8919 if(z==0&&fakez==0)
8920 {
8921 if(cmb.usrflags&cflag10)
8922 {
8923 if(!switchblock_offset)
8924 {
8925 switchblock_offset=true;
8926 yofs -= 8;
8927 }
8928 }
8929 else
8930 {
8931 if(switchblock_offset)
8932 {
8933 switchblock_offset=false;
8934 yofs += 8;
8935 }
8936 }
8937 }
8938 if(cmb.attributes[2]>0 && switchblock_z>=0)
8939 {
8940 if(z==0&&fakez==0)
8941 switchblock_z = zc_max(switchblock_z,zslongToFix(cmb.attributes[2]));
8942 else if(SWITCHBLOCK_STATE < zslongToFix(cmb.attributes[2]))
8943 {
8944 switchblock_z += zslongToFix(cmb.attributes[2])-SWITCHBLOCK_STATE;
8945 }
8946 }
8947 else switchblock_z = -1;
8948 break;
8949 }
8950 }
8951 6157976 }
8952 6158437 }
8953 6419923 ClearhitHeroUIDs(); //clear them before we advance.
8954 6419923 checkhit();
8955
8956 6419923 bool forcedeath = dying_flags&DYING_FORCED;
8957 6419923 bool norev = (dying_flags&DYING_NOREV);
8958
4/6
✓ Branch 0 taken 6419923 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 118 times.
✓ Branch 3 taken 6419805 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 118 times.
6419923 if(forcedeath || (game->get_life()<=0 && !immortal))
8959 {
8960
1/2
✓ Branch 0 taken 118 times.
✗ Branch 1 not taken.
118 if(forcedeath)
8961 game->set_life(0);
8962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
118 if(!norev)
8963
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 30208 times.
30326 for(size_t slot = 0; slot < 256; ++slot)
8964 {
8965
1/2
✓ Branch 0 taken 30208 times.
✗ Branch 1 not taken.
30208 if(size_t bind = game->get_bottle_slot(slot))
8966 {
8967 bottletype const* bt = &QMisc.bottle_types[bind-1];
8968 if(!(bt->flags&BTFLAG_AUTOONDEATH))
8969 continue;
8970 word toFill[3] = { 0 };
8971 for(size_t q = 0; q < 3; ++q)
8972 {
8973 char c = bt->counter[q];
8974 if(c > -1)
8975 {
8976 if(bt->flags & (1<<q))
8977 {
8978 toFill[q] = (bt->amount[q]==100)
8979 ? game->get_maxcounter(c)
8980 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
8981 }
8982 else toFill[q] = bt->amount[q];
8983 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
8984 {
8985 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
8986 }
8987 }
8988 }
8989 if(bt->flags & BTFLAG_CURESWJINX)
8990 {
8991 swordclk = 0;
8992 verifyAWpn();
8993 }
8994 if(bt->flags & BTFLAG_CUREITJINX)
8995 itemclk = 0;
8996 if(word max = std::max(toFill[0], std::max(toFill[1], toFill[2])))
8997 {
8998 int32_t itemid = find_bottle_for_slot(slot,true);
8999 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
9000 if(itemid > -1)
9001 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
9002 for(size_t q = 0; q < 20; ++q)
9003 do_death_refill_waitframe();
9004 double inc = max/60.0; //1 second
9005 double xtra[3]{ 0 };
9006 for(size_t q = 0; q < 60; ++q)
9007 {
9008 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
9009 sfx(QMisc.miscsfx[sfxREFILL]);
9010 for(size_t j = 0; j < 3; ++j)
9011 {
9012 xtra[j] += inc;
9013 word f = floor(xtra[j]);
9014 xtra[j] -= f;
9015 if(toFill[j] > f)
9016 {
9017 toFill[j] -= f;
9018 game->change_counter(f,bt->counter[j]);
9019 }
9020 else if(toFill[j])
9021 {
9022 game->change_counter(toFill[j],bt->counter[j]);
9023 toFill[j] = 0;
9024 }
9025 }
9026 do_death_refill_waitframe();
9027 }
9028 for(size_t j = 0; j < 3; ++j)
9029 {
9030 if(toFill[j])
9031 {
9032 game->change_counter(toFill[j],bt->counter[j]);
9033 toFill[j] = 0;
9034 }
9035 }
9036 for(size_t q = 0; q < 20; ++q)
9037 do_death_refill_waitframe();
9038 }
9039 game->set_bottle_slot(slot,bt->next_type);
9040 if(game->get_life() > 0)
9041 {
9042 dying_flags = 0;
9043 forcedeath = false;
9044 break; //Revived! Stop drinking things...
9045 }
9046 }
9047 30326 }
9048
9049
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 106 times.
118 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
9050 {
9051
3/6
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
12 if(forcedeath || (game->get_life()<=0 && !immortal)) //Not saved by fairy
9052 {
9053 // So scripts can have one frame to handle hp zero events
9054
3/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 11 times.
12 if(norev || false == (last_hurrah = !last_hurrah))
9055 {
9056 1 dying_flags = 0;
9057 1 drunkclk=0;
9058 1 lstunclock = 0;
9059 1 is_conveyor_stunned = 0;
9060 1 FFCore.setHeroAction(dying);
9061 1 FFCore.deallocateAllArrays(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME);
9062 1 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE);
9063 1 ALLOFF(true,true);
9064 1 GameFlags |= GAMEFLAG_NO_F6;
9065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!debug_enabled)
9066 {
9067 1 Paused=false;
9068 1 }
9069
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!get_bit(quest_rules,qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9070 {
9071 FFCore.runOnDeathEngine();
9072 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH);
9073 }
9074 1 Playing = false;
9075 1 heroDeathAnimation();
9076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(get_bit(quest_rules,qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9077 {
9078 1 Playing = true;
9079 1 FFCore.runOnDeathEngine();
9080 1 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH);
9081 1 Playing = false;
9082 1 }
9083 1 GameFlags &= ~GAMEFLAG_NO_F6;
9084 1 ALLOFF(true,true);
9085 1 return true;
9086 }
9087 11 }
9088 11 }
9089 else //2.50.x
9090 {
9091 // So scripts can have one frame to handle hp zero events
9092
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 53 times.
106 if(false == (last_hurrah = !last_hurrah))
9093 {
9094 53 drunkclk=0;
9095 53 heroDeathAnimation();
9096
9097 53 return true;
9098 }
9099 }
9100 64 }
9101 6419805 else last_hurrah=false;
9102
9103
2/2
✓ Branch 0 taken 6387420 times.
✓ Branch 1 taken 32449 times.
6419869 if(swordclk>0)
9104 {
9105 32449 --swordclk;
9106
2/2
✓ Branch 0 taken 32294 times.
✓ Branch 1 taken 155 times.
32449 if(!swordclk) verifyAWpn();
9107 32449 }
9108
2/2
✓ Branch 0 taken 6415811 times.
✓ Branch 1 taken 4058 times.
6419869 if(itemclk>0)
9109 4058 --itemclk;
9110
9111
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 6419577 times.
6419869 if(inwallm)
9112 {
9113 292 attackclk=0;
9114 292 herostep();
9115
9116
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 3 times.
292 if(CarryHero()==false)
9117 3 restart_level();
9118
9119 292 solid_update(false);
9120 292 return false;
9121 }
9122
9123
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6419576 times.
6419577 if(ewind_restart)
9124 {
9125 1 attackclk=0;
9126 1 restart_level();
9127 1 xofs=0;
9128 1 action=none; FFCore.setHeroAction(none);
9129 1 ewind_restart=false;
9130 1 solid_update(false);
9131 1 return false;
9132 }
9133
9134
2/2
✓ Branch 0 taken 6413453 times.
✓ Branch 1 taken 6123 times.
6419576 if(hopclk)
9135 {
9136 6123 action=hopping; FFCore.setHeroAction(hopping);
9137 6123 }
9138
2/2
✓ Branch 0 taken 6419366 times.
✓ Branch 1 taken 210 times.
6419576 if(fallclk)
9139 {
9140 210 action=falling; FFCore.setHeroAction(falling);
9141 210 }
9142
9143 6419576 handle_passive_buttons();
9144
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 6419456 times.
6419576 if(liftclk)
9145 {
9146
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(lift_wpn)
9147 {
9148 120 action=lifting; FFCore.setHeroAction(lifting);
9149 120 }
9150 else
9151 {
9152 liftclk = 0;
9153 tliftclk = 0;
9154 }
9155 120 }
9156
2/2
✓ Branch 0 taken 6419142 times.
✓ Branch 1 taken 314 times.
6419456 else if(lift_wpn)
9157 {
9158 314 handle_lift(false);
9159 314 }
9160
9161
9162 // get user input or do other animation
9163 6419576 freeze_guys=false; // reset this flag, set it again if holding
9164
9165
14/16
✓ Branch 0 taken 6378068 times.
✓ Branch 1 taken 41508 times.
✓ Branch 2 taken 6364674 times.
✓ Branch 3 taken 13394 times.
✓ Branch 4 taken 6364024 times.
✓ Branch 5 taken 650 times.
✓ Branch 6 taken 6363894 times.
✓ Branch 7 taken 130 times.
✓ Branch 8 taken 6363894 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6363894 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6347533 times.
✓ Branch 13 taken 16361 times.
✓ Branch 14 taken 22 times.
✓ Branch 15 taken 6347511 times.
6419576 if(action != landhold1 && action != landhold2 && action != waterhold1 && action != waterhold2 && action != sidewaterhold1 && action != sidewaterhold2 && fairyclk==0 && holdclk>0)
9166 {
9167 22 holdclk=0;
9168 22 }
9169
9170 6419576 active_shield_id = refreshActiveShield();
9171 6419576 bool sh = active_shield_id > -1;
9172 6419576 itemdata const& shield = itemsbuf[active_shield_id];
9173 //Handle direction forcing. This runs every frame so that scripts can interact with dir still.
9174 6419576 shield_forcedir = -1;
9175
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6419576 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6419576 if(sh && action != rafting && (shield.flags & ITEM_FLAG11)) //Lock Dir
9176 {
9177 shield_forcedir = dir;
9178 }
9179
1/2
✓ Branch 0 taken 6419576 times.
✗ Branch 1 not taken.
6419576 if(sh != shield_active) //Toggle active shield on/off
9180 {
9181 shield_active = sh;
9182 if(sh) //Toggle active shield on
9183 {
9184 sfx(shield.usesound2); //'Activate' sfx
9185 }
9186 }
9187
9188 6419576 bool isthissolid = false;
9189
11/12
✓ Branch 0 taken 64741 times.
✓ Branch 1 taken 780 times.
✓ Branch 2 taken 640 times.
✓ Branch 3 taken 104764 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 54902 times.
✓ Branch 6 taken 6129974 times.
✓ Branch 7 taken 47555 times.
✓ Branch 8 taken 210 times.
✓ Branch 9 taken 6123 times.
✓ Branch 10 taken 9767 times.
✓ Branch 11 taken 120 times.
6419576 switch(action)
9190 {
9191 case gothit:
9192
2/2
✓ Branch 0 taken 46132 times.
✓ Branch 1 taken 1423 times.
47555 if(attackclk)
9193
2/2
✓ Branch 0 taken 1235 times.
✓ Branch 1 taken 188 times.
1611 if(!doattack())
9194 {
9195 188 attackclk=spins=0;
9196 188 tapping=false;
9197 188 }
9198
9199 47555 break;
9200
9201 case drowning:
9202 case lavadrowning:
9203 case sidedrowning:
9204 {
9205 640 herostep(); // maybe this line should be elsewhere?
9206
9207 //!DROWN
9208 // Helpful comment to find drowning -Dimi
9209
9210 640 drop_liftwpn();
9211
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 10 times.
640 if(--drownclk==0)
9212 {
9213 10 action=none; FFCore.setHeroAction(none);
9214 10 int32_t water = iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9215 10 int32_t damage = combobuf[water].attributes[0]/10000L;
9216 //if (damage == 0 && !(combobuf[water].usrflags&cflag7)) damage = (game->get_hp_per_heart()/4);
9217 10 drownCombo = 0;
9218
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if (combobuf[water].type != cWATER) damage = 4;
9219
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10 if(cheat_superman && damage > 0)
9220 damage = 0;
9221
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(damage)
9222 10 game->set_life(vbound(game->get_life()-damage,0, game->get_maxlife()));
9223 10 go_respawn_point();
9224 10 hclk=48;
9225 10 }
9226
9227 640 break;
9228 }
9229 case falling:
9230 {
9231 210 herostep();
9232 210 pitfall();
9233 210 break;
9234 }
9235 case freeze:
9236 case sideswimfreeze:
9237 case scrolling:
9238 104764 break;
9239
9240 case casting:
9241 case sideswimcasting:
9242 {
9243 if(magicitem==-1)
9244 {
9245 action=none; FFCore.setHeroAction(none);
9246 }
9247
9248 break;
9249 }
9250 case landhold1:
9251 case landhold2:
9252 {
9253
2/2
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 54480 times.
54902 if(--holdclk <= 0)
9254 {
9255 //restart music
9256
4/4
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 359 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 28 times.
422 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9257 28 playLevelMusic();
9258
9259 422 action=none; FFCore.setHeroAction(none);
9260 422 post_item_collect();
9261 422 }
9262 else
9263 54480 freeze_guys=true;
9264
9265 54902 break;
9266 }
9267 case waterhold1:
9268 case waterhold2:
9269 case sidewaterhold1:
9270 case sidewaterhold2:
9271 {
9272 780 diveclk=0;
9273
9274
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 774 times.
780 if(--holdclk <= 0)
9275 {
9276 //restart music
9277
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9278 playLevelMusic();
9279
9280 6 SetSwim();
9281 6 post_item_collect();
9282 6 }
9283 else
9284 774 freeze_guys=true;
9285
9286 780 break;
9287 }
9288 case hopping:
9289 {
9290
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6123 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6123 if(DRIEDLAKE)
9291 {
9292 action=none; FFCore.setHeroAction(none);
9293 hopclk = 0;
9294 diveclk = 0;
9295 break;
9296 }
9297
9298 6123 do_hopping();
9299 6123 break;
9300 }
9301 case inwind:
9302 {
9303 9767 int32_t i=Lwpns.idFirst(wWind);
9304
9305
2/2
✓ Branch 0 taken 9634 times.
✓ Branch 1 taken 133 times.
9767 if(i<0)
9306 {
9307 133 bool exit=false;
9308
9309
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 67 times.
133 if(whirlwind==255)
9310 {
9311 66 exit=true;
9312 66 }
9313
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
67 else if(y<=0 && dir==up) y=-1;
9314
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
67 else if(y>=160 && dir==down) y=161;
9315
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
67 else if(x<=0 && dir==left) x=-1;
9316
2/4
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 67 times.
67 else if(x>=240 && dir==right) x=241;
9317 else exit=true;
9318
9319
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 66 times.
133 if(exit)
9320 {
9321 66 action=none; FFCore.setHeroAction(none);
9322 66 xofs=0;
9323 66 whirlwind=0;
9324 66 lstep=0;
9325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if ( dontdraw < 2 ) dontdraw=0;
9326 66 set_respawn_point();
9327 66 }
9328 133 }
9329 /*
9330 else if (((weapon*)Lwpns.spr(i))->dead==1)
9331 {
9332 whirlwind=255;
9333 }
9334 */
9335 else
9336 {
9337 9634 x=Lwpns.spr(i)->x;
9338 9634 y=Lwpns.spr(i)->y;
9339 9634 dir=Lwpns.spr(i)->dir;
9340 }
9341 }
9342 9767 break;
9343 case lifting:
9344 120 handle_lift();
9345 120 break;
9346
9347 case sideswimming:
9348 case sideswimattacking:
9349 case sideswimhit:
9350 case swimhit:
9351 case swimming:
9352 {
9353
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 64741 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
64741 if(DRIEDLAKE)
9354 {
9355 action=none; FFCore.setHeroAction(none);
9356 hopclk=0;
9357 break;
9358 }
9359
9360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64741 times.
64741 bool shouldbreak = (action == sideswimhit || action == swimhit); //!DIMITODO: "Can walk while hurt" compat needs to be added here.
9361
9362
4/4
✓ Branch 0 taken 32339 times.
✓ Branch 1 taken 32402 times.
✓ Branch 2 taken 259 times.
✓ Branch 3 taken 32080 times.
64741 if((frame&1) && !shouldbreak)
9363 32080 herostep();
9364
9365
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 64741 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64741 times.
✓ Branch 4 taken 2282 times.
✓ Branch 5 taken 62459 times.
67023 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
9366
4/6
✓ Branch 0 taken 62459 times.
✓ Branch 1 taken 2282 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2282 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2282 times.
64741 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
9367
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2282 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2282 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2282 times.
2282 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
9368
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2282 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2282 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2282 times.
64741 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
9369
4/4
✓ Branch 0 taken 63474 times.
✓ Branch 1 taken 1267 times.
✓ Branch 2 taken 63474 times.
✓ Branch 3 taken 1267 times.
64741 if ((get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) //Since hopping won't be set with this on, something needs to kick Hero out of water...
9370 {
9371
4/4
✓ Branch 0 taken 1264 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1255 times.
✓ Branch 3 taken 1 times.
2523 if(!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+9), currmap, currscr, -1, x.getInt()+4,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+15), currmap, currscr, -1, x.getInt()+4,y.getInt()+15, true, false)
9372
4/4
✓ Branch 0 taken 1262 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1256 times.
✓ Branch 3 taken 6 times.
1264 || !iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+9), currmap, currscr, -1, x.getInt()+11,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+15), currmap, currscr, -1, x.getInt()+11,y.getInt()+15, true, false))
9373 {
9374 12 hopclk=0;
9375 12 diveclk=0;
9376
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if (action != sideswimattacking && action != attacking) {action=none; FFCore.setHeroAction(none);}
9377 else {action=attacking; FFCore.setHeroAction(attacking);}
9378 12 hopdir=-1;
9379 12 }
9380 1267 }
9381
2/2
✓ Branch 0 taken 527 times.
✓ Branch 1 taken 64214 times.
64741 if (shouldbreak) break;
9382
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 64202 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
64214 if (action == swimming || action == sideswimming || action == sideswimattacking)
9383 {
9384 64202 int32_t watercheck = iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64202 times.
64202 if (combobuf[watercheck].usrflags&cflag2)
9386 {
9387 if (current_item(combobuf[watercheck].attribytes[2]) < combobuf[watercheck].attribytes[3])
9388 {
9389 onpassivedmg = true;
9390 if (damageovertimeclk == 0)
9391 {
9392 int32_t curhp = game->get_life();
9393 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
9394 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
9395 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
9396 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
9397 {
9398 hclk = 48;
9399 hitdir = -1;
9400 if (IsSideSwim()) {action = sideswimhit; FFCore.setHeroAction(sideswimhit);}
9401 else {action = swimhit; FFCore.setHeroAction(swimhit);}
9402 }
9403 }
9404 if (combobuf[watercheck].attribytes[1] > 0)
9405 {
9406 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
9407 else --damageovertimeclk;
9408 }
9409 else damageovertimeclk = 0;
9410 }
9411 else damageovertimeclk = 0;
9412 }
9413 64202 else damageovertimeclk = 0;
9414 //combobuf[watercheck].attributes[0]
9415 64202 }
9416
9417 64214 }
9418 [[fallthrough]];
9419 default:
9420 // call the main movement routine
9421
2/2
✓ Branch 0 taken 15396 times.
✓ Branch 1 taken 6178792 times.
6194188 if(get_bit(quest_rules,qr_NEW_HERO_MOVEMENT2))
9422 {
9423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15396 times.
15396 if(premove())
9424 15396 movehero();
9425 15396 }
9426 6178792 else moveheroOld();
9427 6194188 }
9428
9429
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6419576 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6419576 if(shield_forcedir > -1 && action != rafting)
9430 dir = shield_forcedir;
9431
9432
2/2
✓ Branch 0 taken 6391931 times.
✓ Branch 1 taken 27645 times.
6419576 if(!get_bit(quest_rules,qr_OLD_RESPAWN_POINTS))
9433 27645 set_respawn_point(false); //Keep the 'last safe location' updated!
9434
9435 // check for ladder removal
9436
2/2
✓ Branch 0 taken 712239 times.
✓ Branch 1 taken 5707337 times.
6419576 if(diagonalMovement)
9437 {
9438
2/2
✓ Branch 0 taken 712203 times.
✓ Branch 1 taken 36 times.
712239 if(ladderx+laddery)
9439 {
9440
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(ladderdir==up)
9441 {
9442 if((laddery-y.getInt()>=(16+(ladderstart==dir?ladderstart==down?1:0:0))) || (laddery-y.getInt()<=(-16-(ladderstart==dir?ladderstart==up?1:0:0))) || (abs(ladderx-x.getInt())>8))
9443 {
9444 reset_ladder();
9445 }
9446 }
9447 else
9448 {
9449
9/10
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 26 times.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 33 times.
36 if((abs(laddery-y.getInt())>8) || (ladderx-x.getInt()>=(16+(ladderstart==dir?ladderstart==right?1:0:0))) || (ladderx-x.getInt()<=(-16-(ladderstart==dir?ladderstart==left?1:0:0))))
9450 {
9451 3 reset_ladder();
9452 3 }
9453 }
9454 36 }
9455 712239 }
9456 else
9457 {
9458
4/4
✓ Branch 0 taken 224933 times.
✓ Branch 1 taken 5482404 times.
✓ Branch 2 taken 121768 times.
✓ Branch 3 taken 103165 times.
5707337 if((abs(laddery-y.getInt())>=16) || (abs(ladderx-x.getInt())>=16))
9459 {
9460 5604172 reset_ladder();
9461 5604172 }
9462 }
9463
9464
2/2
✓ Branch 0 taken 897 times.
✓ Branch 1 taken 6418679 times.
6419576 if(ilswim)
9465 897 landswim++;
9466 6418679 else landswim=0;
9467
9468
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6419574 times.
6419576 if(hopclk!=0xFF) ilswim=false;
9469
9470
3/4
✓ Branch 0 taken 13125 times.
✓ Branch 1 taken 6406451 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13125 times.
6419576 if((!loaded_guys) && (frame - newscr_clk >= 1))
9471 {
9472
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13112 times.
13125 if(tmpscr->room==rGANON)
9473 {
9474 13 ganon_intro();
9475 13 }
9476 else
9477 {
9478 13112 loadguys();
9479 }
9480 13125 }
9481
9482
2/2
✓ Branch 0 taken 13688 times.
✓ Branch 1 taken 6405888 times.
6419576 if(frame - newscr_clk >= 2)
9483 {
9484 6405888 loadenemies();
9485 6405888 }
9486
9487 // check lots of other things
9488 6419576 checkscroll();
9489
9490
6/8
✓ Branch 0 taken 6409874 times.
✓ Branch 1 taken 9702 times.
✓ Branch 2 taken 6409244 times.
✓ Branch 3 taken 630 times.
✓ Branch 4 taken 6409244 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6409244 times.
6419576 if(action!=inwind && action!=drowning && action != sidedrowning && action!=lavadrowning)
9491 {
9492 6409244 checkspecial();
9493 6409244 checkitems();
9494 6409244 checklocked(); //This has issues if Hero's action is WALKING, in 8-way moveent.
9495
2/2
✓ Branch 0 taken 28146 times.
✓ Branch 1 taken 6381098 times.
6409244 if(get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
9496 {
9497 6381098 oldchecklockblock();
9498 6381098 oldcheckbosslockblock();
9499 6381098 }
9500
2/2
✓ Branch 0 taken 157813 times.
✓ Branch 1 taken 6251431 times.
6409244 if(get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
9501 {
9502 6251431 oldcheckchest(cCHEST);
9503 6251431 oldcheckchest(cLOCKEDCHEST);
9504 6251431 oldcheckchest(cBOSSCHEST);
9505 6251431 }
9506 6409244 checkpushblock();
9507 6409244 checkswordtap();
9508
9509
2/2
✓ Branch 0 taken 4732 times.
✓ Branch 1 taken 6404512 times.
6409244 if(hookshot_frozen==false)
9510 {
9511 6404512 checkspecial2(&lsave);
9512 6404512 }
9513
9514
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 6409236 times.
6409244 if(action==won)
9515 {
9516 8 return true;
9517 }
9518 6409236 }
9519
9520 // Somehow Hero was displaced from the fairy flag...
9521
3/6
✓ Branch 0 taken 16361 times.
✓ Branch 1 taken 6403207 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16361 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6419568 if(fairyclk && action != freeze && action != sideswimfreeze)
9522 {
9523 fairyclk = holdclk = refill_why = 0;
9524 }
9525
9526
4/4
✓ Branch 0 taken 6419566 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 9978 times.
✓ Branch 3 taken 6409588 times.
6419568 if((!activated_timed_warp) && (tmpscr->timedwarptics>0))
9527 {
9528 9978 tmpscr->timedwarptics--;
9529
9530
2/2
✓ Branch 0 taken 9938 times.
✓ Branch 1 taken 40 times.
9978 if(tmpscr->timedwarptics==0)
9531 {
9532 40 activated_timed_warp=true;
9533
9534
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 3 times.
40 if(tmpscr->flags4 & fTIMEDDIRECT)
9535 {
9536 3 didpit=true;
9537 3 pitx=x;
9538 3 pity=y;
9539 3 }
9540
9541 40 int32_t index2 = 0;
9542
9543
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(tmpscr->flags5 & fRANDOMTIMEDWARP) index2=zc_oldrand()%4;
9544
9545 40 sdir = dir;
9546 40 dowarp(1,index2);
9547 40 }
9548 9978 }
9549
9550 6419568 bool awarp = false;
9551 //!DIMI: Global Combo Effects (AUTO STUFF)
9552
2/2
✓ Branch 0 taken 292478 times.
✓ Branch 1 taken 6419568 times.
6712046 for(auto& p : slopes)
9553 {
9554 292478 slope_object& s = p.second;
9555 292478 s.updateslope(); //sets old x/y poses
9556 }
9557
2/2
✓ Branch 0 taken 6419567 times.
✓ Branch 1 taken 1129843590 times.
1136263157 for(int32_t i=0; i<176; ++i)
9558 {
9559
2/2
✓ Branch 0 taken 4713280 times.
✓ Branch 1 taken 4533514197 times.
4538227477 for(int32_t layer=0; layer<7; ++layer)
9560 {
9561
2/2
✓ Branch 0 taken 1129843590 times.
✓ Branch 1 taken 3403670607 times.
4533514197 int32_t cid = ( layer ) ? MAPCOMBOL(layer,COMBOX(i),COMBOY(i)) : MAPCOMBO(COMBOX(i),COMBOY(i));
9562 4533514197 newcombo const& cmb = combobuf[cid];
9563
9564
2/2
✓ Branch 0 taken 32992960 times.
✓ Branch 1 taken 4500521237 times.
4533514197 if(!get_bit(quest_rules,qr_AUTOCOMBO_ANY_LAYER))
9565 {
9566
2/2
✓ Branch 0 taken 1125130309 times.
✓ Branch 1 taken 3375390928 times.
4500521237 if(layer > 2) break;
9567
4/4
✓ Branch 0 taken 1125130309 times.
✓ Branch 1 taken 2250260619 times.
✓ Branch 2 taken 1101968885 times.
✓ Branch 3 taken 23161424 times.
3375390928 if (layer == 1 && !get_bit(quest_rules,qr_AUTOCOMBO_LAYER_1)) continue;
9568
4/4
✓ Branch 0 taken 1125130309 times.
✓ Branch 1 taken 1148291734 times.
✓ Branch 2 taken 23161424 times.
✓ Branch 3 taken 1101968885 times.
2273422043 if (layer == 2 && !get_bit(quest_rules,qr_AUTOCOMBO_LAYER_2)) continue;
9569 1171453158 }
9570 1204446118 int32_t ind=0;
9571
9572 //AUTOMATIC TRIGGER CODE
9573
2/2
✓ Branch 0 taken 1204432032 times.
✓ Branch 1 taken 14086 times.
1204446118 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
9574 {
9575 14086 do_trigger_combo(layer, i);
9576 14086 }
9577
9578 //AUTO WARP CODE
9579
2/2
✓ Branch 0 taken 19463 times.
✓ Branch 1 taken 1204426655 times.
1204446118 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
9580 {
9581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1204426655 times.
1204426655 if(cmb.type==cAWARPA)
9582 {
9583 awarp=true;
9584 ind=0;
9585 }
9586
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1204426654 times.
1204426655 else if(cmb.type==cAWARPB)
9587 {
9588 1 awarp=true;
9589 1 ind=1;
9590 1 }
9591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1204426654 times.
1204426654 else if(cmb.type==cAWARPC)
9592 {
9593 awarp=true;
9594 ind=2;
9595 }
9596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1204426654 times.
1204426654 else if(cmb.type==cAWARPD)
9597 {
9598 awarp=true;
9599 ind=3;
9600 }
9601
1/2
✓ Branch 0 taken 1204426654 times.
✗ Branch 1 not taken.
1204426654 else if(cmb.type==cAWARPR)
9602 {
9603 awarp=true;
9604 ind=zc_oldrand()%4;
9605 }
9606 1204426655 }
9607
2/2
✓ Branch 0 taken 1204446117 times.
✓ Branch 1 taken 1 times.
1204446118 if(awarp)
9608 {
9609
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(tmpscr->flags5&fDIRECTAWARP)
9610 {
9611 didpit=true;
9612 pitx=x;
9613 pity=y;
9614 }
9615
9616 1 sdir = dir;
9617 1 dowarp(1,ind);
9618 1 break;
9619 }
9620 1204446117 }
9621
2/2
✓ Branch 0 taken 1129843589 times.
✓ Branch 1 taken 1 times.
1129843590 if(awarp) break;
9622 1129843589 }
9623
9624 6419568 awarp=false;
9625
9626 6419568 word c = tmpscr->numFFC();
9627
2/2
✓ Branch 0 taken 6419551 times.
✓ Branch 1 taken 201309318 times.
207728869 for(word i=0; i<c; i++)
9628 {
9629 201309318 int32_t ind=0;
9630
9631 201309318 newcombo const& cmb = combobuf[tmpscr->ffcs[i].getData()];
9632
9633
1/2
✓ Branch 0 taken 201309318 times.
✗ Branch 1 not taken.
201309318 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
9634 {
9635 do_trigger_combo_ffc(i);
9636 }
9637
9638
2/2
✓ Branch 0 taken 3908 times.
✓ Branch 1 taken 201305410 times.
201309318 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
9639 {
9640
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 201305404 times.
201305410 if(cmb.type==cAWARPA)
9641 {
9642 6 awarp=true;
9643 6 ind=0;
9644 6 }
9645
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 201305397 times.
201305404 else if(cmb.type==cAWARPB)
9646 {
9647 7 awarp=true;
9648 7 ind=1;
9649 7 }
9650
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 201305396 times.
201305397 else if(cmb.type==cAWARPC)
9651 {
9652 1 awarp=true;
9653 1 ind=2;
9654 1 }
9655
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 201305393 times.
201305396 else if(cmb.type==cAWARPD)
9656 {
9657 3 awarp=true;
9658 3 ind=3;
9659 3 }
9660
1/2
✓ Branch 0 taken 201305393 times.
✗ Branch 1 not taken.
201305393 else if(cmb.type==cAWARPR)
9661 {
9662 awarp=true;
9663 ind=zc_oldrand()%4;
9664 }
9665 201305410 }
9666
9667
2/2
✓ Branch 0 taken 201309301 times.
✓ Branch 1 taken 17 times.
201309318 if(awarp)
9668 {
9669
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tmpscr->flags5&fDIRECTAWARP)
9670 {
9671 didpit=true;
9672 pitx=x;
9673 pity=y;
9674 }
9675
9676 17 sdir = dir;
9677 17 dowarp(1,ind);
9678 17 break;
9679 }
9680 201309301 }
9681 6419568 zfix dx, dy;
9682
7/8
✓ Branch 0 taken 261478 times.
✓ Branch 1 taken 6158090 times.
✓ Branch 2 taken 131408 times.
✓ Branch 3 taken 130070 times.
✓ Branch 4 taken 3777 times.
✓ Branch 5 taken 127631 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3777 times.
6419568 if (sideview_mode() && !on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && on_sideview_solid_oldpos(x, y,old_x,old_y, false, 2) && !toogam)
9683 {
9684
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 3723 times.
3777 if (slide_slope(this, dx, dy, slopeid))
9685 {
9686 3723 onplatid = 5;
9687
3/4
✓ Branch 0 taken 2066 times.
✓ Branch 1 taken 1657 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2066 times.
3723 if (dx || dy) push_move(dx, dy);
9688 3723 }
9689 3777 }
9690
2/2
✓ Branch 0 taken 6414989 times.
✓ Branch 1 taken 4579 times.
6419568 if (onplatid <= 0) slopeid = 0;
9691 4579 else --onplatid;
9692
2/2
✓ Branch 0 taken 4955822 times.
✓ Branch 1 taken 1463746 times.
6419568 bool onplatform = (on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && !Up());
9693
5/6
✓ Branch 0 taken 1460 times.
✓ Branch 1 taken 6419555 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1460 times.
✓ Branch 4 taken 1447 times.
✓ Branch 5 taken 6419568 times.
6421015 for (auto q = 0; (check_slope(this, true) && !toogam) && q < 2; ++q)
9694 {
9695
2/4
✓ Branch 0 taken 1447 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1447 times.
1447 if (check_slope(this, true) && !toogam)
9696 {
9697 1447 slope_info const& s = get_slope(this, true).get_info();
9698 1447 bool staircheck = false;
9699
4/4
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 1284 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 75 times.
1447 if (s.slope() != slopeid && slopeid) staircheck = true;
9700
2/2
✓ Branch 0 taken 1395 times.
✓ Branch 1 taken 52 times.
1447 if (onplatform) staircheck = true;
9701 1447 slope_push_int(s, this, dx, dy, staircheck, platformfell2);
9702
9703
4/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 1060 times.
✓ Branch 2 taken 365 times.
✓ Branch 3 taken 22 times.
1447 if (dx || dy)
9704 {
9705 1425 int32_t pushret = push_move(dx,dy);
9706
2/2
✓ Branch 0 taken 1388 times.
✓ Branch 1 taken 37 times.
1425 onplatform = (on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && !Up());
9707
4/4
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 1268 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 73 times.
1425 if (s.slope() != slopeid && slopeid) staircheck = true;
9708
2/2
✓ Branch 0 taken 1393 times.
✓ Branch 1 taken 32 times.
1425 if (onplatform) staircheck = true;
9709
4/4
✓ Branch 0 taken 1347 times.
✓ Branch 1 taken 78 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 1333 times.
1425 if(sideview_mode() && slopeid)
9710 1333 onplatid = 5;
9711
1/2
✓ Branch 0 taken 1425 times.
✗ Branch 1 not taken.
1425 if (pushret == 1)
9712 {
9713 dx = -1;
9714 dy = 0;
9715 slope_push_int(s, this, dx, dy, staircheck);
9716 push_move(dx,dy);
9717 }
9718
2/2
✓ Branch 0 taken 1407 times.
✓ Branch 1 taken 18 times.
1425 if (pushret == 2)
9719 {
9720 18 dx = 0;
9721 18 dy = -1;
9722 18 slope_push_int(s, this, dx, dy, staircheck);
9723 18 push_move(dx,dy);
9724 18 }
9725 1425 }
9726 1447 }
9727 1447 }
9728
9729
2/2
✓ Branch 0 taken 6419363 times.
✓ Branch 1 taken 205 times.
6419568 if(ffwarp)
9730 {
9731
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 126 times.
205 if(ffpit)
9732 {
9733 126 ffpit=false;
9734 126 didpit=true;
9735 126 pitx=x;
9736 126 pity=y;
9737 126 }
9738
9739 205 ffwarp=false;
9740 205 dowarp(1,0);
9741 205 }
9742
9743 //Hero->WarpEx
9744
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 6419552 times.
6419568 if ( FFCore.warpex[wexActive] )
9745 {
9746 if(DEVLOGGING) zprint("Running warpex from hero.cpp\n");
9747 16 FFCore.warpex[wexActive] = 0;
9748 16 int32_t temp_warpex[wexActive] = {0}; //to hold the values as we clear the FFCore array. -Z
9749
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 16 times.
160 for ( int32_t q = 0; q < wexActive; q++ )
9750 {
9751 144 temp_warpex[q] = FFCore.warpex[q];
9752 144 FFCore.warpex[q] = 0;
9753 144 }
9754 32 FFCore.warp_player( temp_warpex[wexType], temp_warpex[wexDMap], temp_warpex[wexScreen], temp_warpex[wexX],
9755 16 temp_warpex[wexY], temp_warpex[wexEffect], temp_warpex[wexSound], temp_warpex[wexFlags], temp_warpex[wexDir]);
9756 16 }
9757
9758 // walk through bombed doors and fake walls
9759 6419568 bool walk=false;
9760 6419568 int32_t dtype=dBOMBED;
9761
9762
2/2
✓ Branch 0 taken 6243223 times.
✓ Branch 1 taken 176345 times.
6419568 if(pushing>=24) dtype=dWALK;
9763
9764
16/18
✓ Branch 0 taken 3659562 times.
✓ Branch 1 taken 2760006 times.
✓ Branch 2 taken 3619751 times.
✓ Branch 3 taken 39811 times.
✓ Branch 4 taken 3619751 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3614383 times.
✓ Branch 7 taken 5368 times.
✓ Branch 8 taken 3611808 times.
✓ Branch 9 taken 2575 times.
✓ Branch 10 taken 3611157 times.
✓ Branch 11 taken 651 times.
✓ Branch 12 taken 3601306 times.
✓ Branch 13 taken 9851 times.
✓ Branch 14 taken 3601306 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 101062 times.
✓ Branch 17 taken 3702368 times.
6419568 if(isdungeon() && action!=freeze && action != sideswimfreeze && loaded_guys && !inlikelike && !diveclk && action!=rafting && !lstunclock && !is_conveyor_stunned)
9765 {
9766
16/18
✓ Branch 0 taken 100684 times.
✓ Branch 1 taken 3601684 times.
✓ Branch 2 taken 590976 times.
✓ Branch 3 taken 3010708 times.
✓ Branch 4 taken 590861 times.
✓ Branch 5 taken 115 times.
✓ Branch 6 taken 590861 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 590861 times.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 109 times.
✓ Branch 12 taken 130662 times.
✓ Branch 13 taken 460314 times.
✓ Branch 14 taken 38152 times.
✓ Branch 15 taken 92510 times.
✓ Branch 16 taken 38016 times.
✓ Branch 17 taken 136 times.
3702368 if(((dtype==dBOMBED)?DrunkUp():dir==up) && ((diagonalMovement||NO_GRIDLOCK)?x>112&&x<128:x==120) && y<=32 && tmpscr->door[0]==dtype)
9767 {
9768 136 walk=true;
9769 136 dir=up;
9770 136 }
9771
9772
16/18
✓ Branch 0 taken 100684 times.
✓ Branch 1 taken 3601684 times.
✓ Branch 2 taken 388935 times.
✓ Branch 3 taken 3212749 times.
✓ Branch 4 taken 489453 times.
✓ Branch 5 taken 166 times.
✓ Branch 6 taken 489453 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 489453 times.
✓ Branch 10 taken 74 times.
✓ Branch 11 taken 92 times.
✓ Branch 12 taken 75649 times.
✓ Branch 13 taken 413970 times.
✓ Branch 14 taken 22498 times.
✓ Branch 15 taken 53151 times.
✓ Branch 16 taken 22383 times.
✓ Branch 17 taken 115 times.
3702368 if(((dtype==dBOMBED)?DrunkDown():dir==down) && ((diagonalMovement||NO_GRIDLOCK)?x>112&&x<128:x==120) && y>=128 && tmpscr->door[1]==dtype)
9773 {
9774 115 walk=true;
9775 115 dir=down;
9776 115 }
9777
9778
11/16
✓ Branch 0 taken 100684 times.
✓ Branch 1 taken 3601684 times.
✓ Branch 2 taken 59050 times.
✓ Branch 3 taken 3542634 times.
✓ Branch 4 taken 58672 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 58672 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 58672 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 26325 times.
✓ Branch 13 taken 32347 times.
✓ Branch 14 taken 26224 times.
✓ Branch 15 taken 101 times.
3702368 if(((dtype==dBOMBED)?DrunkLeft():dir==left) && x<=32 && ((diagonalMovement||NO_GRIDLOCK)?y>72&&y<88:y==80) && tmpscr->door[2]==dtype)
9779 {
9780 101 walk=true;
9781 101 dir=left;
9782 101 }
9783
9784
11/16
✓ Branch 0 taken 3500622 times.
✓ Branch 1 taken 100684 times.
✓ Branch 2 taken 52160 times.
✓ Branch 3 taken 3448462 times.
✓ Branch 4 taken 72644 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 72644 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 72644 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 35229 times.
✓ Branch 13 taken 37415 times.
✓ Branch 14 taken 35114 times.
✓ Branch 15 taken 115 times.
3601306 if(((dtype==dBOMBED)?DrunkRight():dir==right) && x>=208 && ((diagonalMovement||NO_GRIDLOCK)?y>72&&y<88:y==80) && tmpscr->door[3]==dtype)
9785 {
9786 115 walk=true;
9787 115 dir=right;
9788 115 }
9789 3521106 }
9790
9791
2/2
✓ Branch 0 taken 6439963 times.
✓ Branch 1 taken 467 times.
6440430 if(walk)
9792 {
9793 467 hclk=0;
9794 467 drawguys=false;
9795
9796
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 172 times.
467 if(dtype==dWALK)
9797 {
9798 172 sfx(tmpscr->secretsfx);
9799 172 }
9800
9801 467 action=none; FFCore.setHeroAction(none);
9802 467 attackclk = 0;
9803 467 stepforward(29, true);
9804 467 action=scrolling; FFCore.setHeroAction(scrolling);
9805 467 pushing=false;
9806 467 }
9807
9808
4/6
✓ Branch 0 taken 108730 times.
✓ Branch 1 taken 6331700 times.
✓ Branch 2 taken 108730 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 108730 times.
6440430 if( game->get_life() <= (game->get_hp_per_heart()) && !(game->get_maxlife() <= (game->get_hp_per_heart())) && (heart_beep_timer > -3))
9809 {
9810
1/2
✓ Branch 0 taken 108730 times.
✗ Branch 1 not taken.
108730 if(heart_beep)
9811 {
9812 108730 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
9813 108730 }
9814 else
9815 {
9816 if ( heart_beep_timer == -1 )
9817 {
9818 heart_beep_timer = 70;
9819 }
9820
9821 if ( heart_beep_timer > 0 )
9822 {
9823 --heart_beep_timer;
9824 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
9825 }
9826 else
9827 {
9828 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
9829 }
9830 }
9831 108730 }
9832 else
9833 {
9834
2/2
✓ Branch 0 taken 20864 times.
✓ Branch 1 taken 6310836 times.
6331700 if ( heart_beep_timer > -2 )
9835 {
9836 6310836 heart_beep_timer = -1;
9837 6310836 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
9838 6310836 }
9839 }
9840
9841
2/2
✓ Branch 0 taken 6439664 times.
✓ Branch 1 taken 766 times.
6440430 if(rSbtn())
9842 {
9843 766 int32_t tmp_subscr_clk = frame;
9844
9845 766 int32_t save_type = 0;
9846
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 758 times.
✗ Branch 3 not taken.
766 switch(lsave)
9847 {
9848 case 0:
9849 {
9850
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 717 times.
758 if( FFCore.runActiveSubscreenScriptEngine() )
9851 {
9852 41 break;
9853 }
9854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 717 times.
717 else if ( !stopSubscreenFalling() )
9855 {
9856 717 conveyclk=3;
9857 717 dosubscr(&QMisc);
9858 717 newscr_clk += frame - tmp_subscr_clk;
9859 717 }
9860 717 break;
9861 }
9862
9863
9864 case 2:
9865 save_type = 1;
9866 [[fallthrough]];
9867 case 1:
9868
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(last_savepoint_id)
9869 7 trigger_save(combobuf[last_savepoint_id]);
9870 else save_game((tmpscr->flags4&fSAVEROOM) != 0, save_type); //sanity?
9871 7 break;
9872 }
9873 766 }
9874
9875
2/2
✓ Branch 0 taken 354161 times.
✓ Branch 1 taken 6086267 times.
6440428 if (!checkstab() )
9876 {
9877 /*
9878 for(int32_t q=0; q<176; q++)
9879 {
9880 set_bit(screengrid,q,0);
9881 }
9882
9883 for(int32_t q=0; q<MAXFFCS; q++)
9884 set_bit(ffcgrid, q, 0);
9885 */
9886 6086267 }
9887
9888 6440428 check_conveyor();
9889 6440428 PhantomsCleanup();
9890 //Try to time the hammer pound so that Hero can;t change direction while it occurs.
9891
2/2
✓ Branch 0 taken 6374644 times.
✓ Branch 1 taken 65784 times.
6440428 if(attack==wHammer)
9892 {
9893
6/8
✓ Branch 0 taken 741 times.
✓ Branch 1 taken 65043 times.
✓ Branch 2 taken 741 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 741 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 739 times.
65784 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
9894 {
9895
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 162 times.
✓ Branch 3 taken 213 times.
✓ Branch 4 taken 247 times.
739 switch(dir) //Hero's dir
9896 {
9897 case up:
9898
5/10
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 117 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 117 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 117 times.
✗ Branch 9 not taken.
117 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
9899 117 break;
9900
9901 case down:
9902
5/10
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 162 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
162 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
9903 162 break;
9904
9905 case left:
9906
5/10
✓ Branch 0 taken 213 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 213 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 213 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 213 times.
✗ Branch 9 not taken.
213 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
9907 213 break;
9908
9909 case right:
9910
5/10
✓ Branch 0 taken 247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 247 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 247 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 247 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 247 times.
✗ Branch 9 not taken.
247 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
9911 247 break;
9912 }
9913
9914 739 }
9915 65784 }
9916
9917 6440428 handleSpotlights();
9918
9919
2/2
✓ Branch 0 taken 6440102 times.
✓ Branch 1 taken 326 times.
6440428 if(getOnSideviewLadder())
9920 {
9921
5/8
✓ Branch 0 taken 319 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 319 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 319 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 319 times.
326 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
9922 {
9923 7 setOnSideviewLadder(false);
9924 7 }
9925
4/8
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 213 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 106 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
319 else if(CANFORCEFACEUP)
9926 {
9927 106 setDir(up);
9928 106 }
9929 326 }
9930
2/2
✓ Branch 0 taken 215763 times.
✓ Branch 1 taken 6224665 times.
6440428 if (justmoved > 0) --justmoved;
9931
9932 6440428 return false;
9933 6440783 }
9934
9935 9044 bool HeroClass::push_pixel(zfix dx, zfix dy)
9936 {
9937
2/4
✓ Branch 0 taken 9044 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9044 times.
✗ Branch 3 not taken.
9044 ASSERT(abs(dx) <= 1 && abs(dy) <= 1);
9938
3/4
✓ Branch 0 taken 4371 times.
✓ Branch 1 taken 4673 times.
✓ Branch 2 taken 4371 times.
✗ Branch 3 not taken.
9044 if(dx && dy)
9939 {
9940 bool r = push_pixel(0,dy);
9941 bool r2 = push_pixel(dx,0);
9942 return r && r2;
9943 }
9944
2/2
✓ Branch 0 taken 3684 times.
✓ Branch 1 taken 5360 times.
9044 if(dx < 0)
9945 {
9946
1/2
✓ Branch 0 taken 3684 times.
✗ Branch 1 not taken.
7368 if(!(solpush_walkflag(x+dx,y+(bigHitbox?0:8),1,this)
9947
1/2
✓ Branch 0 taken 3684 times.
✗ Branch 1 not taken.
3684 || solpush_walkflag(x+dx,y+8,1,this)
9948
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3684 times.
✓ Branch 2 taken 3228 times.
✓ Branch 3 taken 456 times.
3684 || (y.getInt()&7?solpush_walkflag(x+dx,y+16,1,this):0)))
9949 {
9950 3684 x += dx;
9951 3684 return true;
9952 }
9953 return false;
9954 }
9955
2/2
✓ Branch 0 taken 687 times.
✓ Branch 1 taken 4673 times.
5360 else if(dx > 0)
9956 {
9957
1/2
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
1374 if(!(solpush_walkflag(x+15+dx,y+(bigHitbox?0:8),1,this)
9958
1/2
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
687 || solpush_walkflag(x+15+dx,y+8,1,this)
9959
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 687 times.
✓ Branch 2 taken 235 times.
✓ Branch 3 taken 452 times.
687 || (y.getInt()&7?solpush_walkflag(x+15+dx,y+16,1,this):0)))
9960 {
9961 687 x += dx;
9962 687 return true;
9963 }
9964 return false;
9965 }
9966
2/2
✓ Branch 0 taken 2484 times.
✓ Branch 1 taken 2189 times.
4673 else if(dy < 0)
9967 {
9968
1/2
✓ Branch 0 taken 2484 times.
✗ Branch 1 not taken.
4968 if(!(solpush_walkflag(x,y+(bigHitbox?0:8)+dy,2,this)
9969
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2484 times.
✓ Branch 2 taken 2257 times.
✓ Branch 3 taken 227 times.
2484 || (x.getInt()&7?solpush_walkflag(x+16,y+(bigHitbox?0:8)+dy,1,this):0)))
9970 {
9971 2484 y += dy;
9972 2484 return true;
9973 }
9974 return false;
9975 }
9976
1/2
✓ Branch 0 taken 2189 times.
✗ Branch 1 not taken.
2189 else if(dy > 0)
9977 {
9978
2/2
✓ Branch 0 taken 2168 times.
✓ Branch 1 taken 21 times.
4357 if(!(solpush_walkflag(x,y+15+dy,2,this)
9979
4/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 2168 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 1866 times.
2189 || (x.getInt()&7?solpush_walkflag(x+16,y+15+dy,1,this):0)))
9980 {
9981 2168 y += dy;
9982 2168 return true;
9983 }
9984 21 return false;
9985 }
9986 return false;
9987 9044 }
9988 4802 int32_t HeroClass::push_move(zfix dx, zfix dy)
9989 {
9990 4802 int32_t ret = 0;
9991
4/4
✓ Branch 0 taken 4371 times.
✓ Branch 1 taken 6234 times.
✓ Branch 2 taken 4802 times.
✓ Branch 3 taken 5803 times.
10605 while(dx || dy)
9992 {
9993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5803 times.
5803 if(check_pitslide() != -1)
9994 break;
9995
2/2
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 4673 times.
5803 if(dy)
9996 {
9997
2/2
✓ Branch 0 taken 2747 times.
✓ Branch 1 taken 1926 times.
4673 zfix cy = (abs(dy) >= 1) ? sign(dy) : dy;
9998 4673 dy -= cy;
9999
2/2
✓ Branch 0 taken 4652 times.
✓ Branch 1 taken 21 times.
4673 if(!push_pixel(0,cy))
10000 {
10001 21 dy = 0;
10002 21 ret |= 2;
10003 21 }
10004 4673 }
10005
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 4371 times.
5803 if(dx)
10006 {
10007
2/2
✓ Branch 0 taken 1673 times.
✓ Branch 1 taken 2698 times.
4371 zfix cx = (abs(dx) >= 1) ? sign(dx) : dx;
10008 4371 dx -= cx;
10009
1/2
✓ Branch 0 taken 4371 times.
✗ Branch 1 not taken.
4371 if(!push_pixel(cx,0))
10010 {
10011 dx = 0;
10012 ret |= 1;
10013 }
10014 4371 }
10015 }
10016 4802 return ret;
10017 }
10018
10019 6419858 bool HeroClass::setSolid(bool set)
10020 {
10021
1/2
✓ Branch 0 taken 6419858 times.
✗ Branch 1 not taken.
6419858 bool actual = set && !toogam; //not solid when noclipping
10022 6419858 bool ret = solid_object::setSolid(actual);
10023 6419858 solid = set;
10024 6419858 return ret;
10025 }
10026
10027 9441 void HeroClass::solid_push(solid_object* obj)
10028 {
10029
1/2
✓ Branch 0 taken 9441 times.
✗ Branch 1 not taken.
9441 if(obj == this) return; //can't push self
10030
10031 9441 zfix dx, dy;
10032 9441 int32_t hdir = -1;
10033 9441 solid_push_int(obj,dx,dy,hdir);
10034
10035
4/4
✓ Branch 0 taken 8382 times.
✓ Branch 1 taken 1059 times.
✓ Branch 2 taken 7739 times.
✓ Branch 3 taken 643 times.
9441 if(!dx && !dy) return;
10036
10037 1702 obj->doContactDamage(hdir);
10038
10039 1702 bool t = obj->getTempNonsolid();
10040 1702 obj->setTempNonsolid(true);
10041
10042 1702 push_move(dx,dy);
10043
10044 1702 obj->setTempNonsolid(t);
10045 9441 }
10046
10047 // A routine used exclusively by startwpn,
10048 // to switch Hero's weapon if his current weapon (bombs) was depleted.
10049 733 void HeroClass::deselectbombs(int32_t super)
10050 {
10051
6/10
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 721 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 721 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 721 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 721 times.
733 if ( get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) || itemsbuf[game->forced_awpn].family == itype_bomb || itemsbuf[game->forced_bwpn].family == itype_bomb || itemsbuf[game->forced_xwpn].family == itype_bomb || itemsbuf[game->forced_ywpn].family == itype_bomb) return;
10052
2/6
✓ Branch 0 taken 721 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 721 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
721 if(getItemFamily(itemsbuf,Bwpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Bwpn==directWpn))
10053 {
10054
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 721 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 721 times.
721 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10055 721 Bwpn = Bweapon(temp);
10056 721 directItemB = directItem;
10057 721 game->bwpn = temp;
10058 721 }
10059
10060 else if (getItemFamily(itemsbuf,Xwpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Xwpn==directWpn))
10061 {
10062 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->xwpn, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10063 Xwpn = Bweapon(temp);
10064 directItemX = directItem;
10065 game->xwpn = temp;
10066 }
10067 else if (getItemFamily(itemsbuf,Ywpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Ywpn==directWpn))
10068 {
10069 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->ywpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, game->awpn);
10070 Ywpn = Bweapon(temp);
10071 directItemY = directItem;
10072 game->ywpn = temp;
10073 }
10074 else
10075 {
10076 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10077 Awpn = Bweapon(temp);
10078 directItemA = directItem;
10079 game->awpn = temp;
10080 }
10081 733 }
10082
10083 int32_t potion_life=0;
10084 int32_t potion_magic=0;
10085
10086 6194927 bool HeroClass::onWater(bool drownonly)
10087 {
10088 6194927 int32_t water = 0;
10089 6194927 int32_t types[4] = {0};
10090 6194927 int32_t x1 = x+4, x2 = x+11,
10091 6194927 y1 = y+9, y2 = y+15;
10092
2/2
✓ Branch 0 taken 240677 times.
✓ Branch 1 taken 5954250 times.
6194927 if (get_bit(quest_rules, qr_SMARTER_WATER))
10093 {
10094
4/4
✓ Branch 0 taken 1619 times.
✓ Branch 1 taken 239058 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1314 times.
241994 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
10095
2/2
✓ Branch 0 taken 1463 times.
✓ Branch 1 taken 156 times.
1619 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
10096
2/2
✓ Branch 0 taken 1317 times.
✓ Branch 1 taken 146 times.
1463 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
10097 1317 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
10098 240677 }
10099 else
10100 {
10101 5954250 types[0] = COMBOTYPE(x1,y1);
10102
10103
2/2
✓ Branch 0 taken 14829 times.
✓ Branch 1 taken 5939421 times.
5954250 if(MAPFFCOMBO(x1,y1))
10104 14829 types[0] = FFCOMBOTYPE(x1,y1);
10105
10106 5954250 types[1] = COMBOTYPE(x1,y2);
10107
10108
2/2
✓ Branch 0 taken 13914 times.
✓ Branch 1 taken 5940336 times.
5954250 if(MAPFFCOMBO(x1,y2))
10109 13914 types[1] = FFCOMBOTYPE(x1,y2);
10110
10111 5954250 types[2] = COMBOTYPE(x2,y1);
10112
10113
2/2
✓ Branch 0 taken 15061 times.
✓ Branch 1 taken 5939189 times.
5954250 if(MAPFFCOMBO(x2,y1))
10114 15061 types[2] = FFCOMBOTYPE(x2,y1);
10115
10116 5954250 types[3] = COMBOTYPE(x2,y2);
10117
10118
2/2
✓ Branch 0 taken 14121 times.
✓ Branch 1 taken 5940129 times.
5954250 if(MAPFFCOMBO(x2,y2))
10119 14121 types[3] = FFCOMBOTYPE(x2,y2);
10120
10121 5954250 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
10122
2/2
✓ Branch 0 taken 14660 times.
✓ Branch 1 taken 5939590 times.
5954250 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
10123 14660 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
10124
10125
5/6
✓ Branch 0 taken 129959 times.
✓ Branch 1 taken 5824291 times.
✓ Branch 2 taken 122938 times.
✓ Branch 3 taken 7021 times.
✓ Branch 4 taken 116653 times.
✗ Branch 5 not taken.
6070903 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
10126
4/4
✓ Branch 0 taken 116788 times.
✓ Branch 1 taken 6150 times.
✓ Branch 2 taken 116653 times.
✓ Branch 3 taken 135 times.
122938 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
10127 116653 water = typec;
10128 }
10129
2/2
✓ Branch 0 taken 6076960 times.
✓ Branch 1 taken 117967 times.
6194927 if(water > 0)
10130 {
10131
1/2
✓ Branch 0 taken 117967 times.
✗ Branch 1 not taken.
117967 if(!drownonly) return true;
10132
4/8
✓ Branch 0 taken 67284 times.
✓ Branch 1 taken 50683 times.
✓ Branch 2 taken 67284 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 67284 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
117967 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
10133 {
10134 50683 return true;
10135 }
10136 67284 }
10137 6144244 return false;
10138 6194927 }
10139
10140 bool HeroClass::mirrorBonk()
10141 {
10142 zfix tx = x, ty = y, tz = z;
10143 WalkflagInfo info = walkflag(x,y+(bigHitbox?0:8),2,up);
10144 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8));
10145 execute(info);
10146 bool fail = info.isUnwalkable();
10147
10148 if(!fail) //not solid, but check for water/pits...
10149 {
10150 if(onWater(true))
10151 fail = true;
10152 if(pitslide() || fallclk)
10153 fail = true;
10154 fallclk = 0;
10155 }
10156 x = tx; y = ty; z = tz;
10157 return fail;
10158 }
10159
10160 void HeroClass::doMirror(int32_t mirrorid)
10161 {
10162 if(z > 0 || fakez > 0) return; //No mirror in air
10163 if(mirrorid < 0)
10164 mirrorid = current_item_id(itype_mirror);
10165 if(mirrorid < 0) return;
10166
10167 if((tmpscr->flags9&fDISABLE_MIRROR) || !(checkbunny(mirrorid) && checkmagiccost(mirrorid)))
10168 {
10169 item_error();
10170 return;
10171 }
10172 static const int32_t sens = 4; //sensitivity of 'No Mirror' combos (0 most, 8 least)
10173 int32_t posarr[] = {COMBOPOS(x+sens,y+sens), COMBOPOS(x+sens,y+15-sens),
10174 COMBOPOS(x+15-sens,y+sens), COMBOPOS(x+15-sens,y+15-sens)};
10175 for(auto pos : posarr)
10176 {
10177 if(HASFLAG_ANY(mfNOMIRROR, pos)) //"No Mirror" flag touching the player
10178 {
10179 item_error();
10180 return;
10181 }
10182 }
10183
10184 itemdata const& mirror = itemsbuf[mirrorid];
10185 if(DMaps[currdmap].flags & dmfMIRRORCONTINUE)
10186 {
10187 paymagiccost(mirrorid);
10188 if(mirror.usesound2) sfx(mirror.usesound2);
10189
10190 doWarpEffect(mirror.misc2, true);
10191 if(mirror.flags & ITEM_FLAG2) //Act as F6->Continue
10192 {
10193 Quit = qCONT;
10194 skipcont = 1;
10195 }
10196 else //Act as Divine Escape
10197 {
10198 int32_t div_prot_temp=div_prot_item;
10199 restart_level();
10200 div_prot_item=div_prot_temp;
10201 magicitem=-1;
10202 magiccastclk=0;
10203 if ( Hero.getDontDraw() < 2 ) { Hero.setDontDraw(0); }
10204 }
10205 }
10206 else
10207 {
10208 int32_t destdmap = DMaps[currdmap].mirrorDMap;
10209 int32_t offscr = currscr - DMaps[currdmap].xoff;
10210 if(destdmap < 0)
10211 return;
10212 int32_t destscr = DMaps[destdmap].xoff + offscr;
10213 if((offscr%16 != destscr%16) || unsigned(destscr) >= 0x80)
10214 return;
10215 paymagiccost(mirrorid);
10216
10217 //Store some values to restore if 'warp fails'
10218 int32_t tLastEntrance = lastentrance,
10219 tLastEntranceDMap = lastentrance_dmap,
10220 tContScr = game->get_continue_scrn(),
10221 tContDMap = game->get_continue_dmap(),
10222 tPortalDMap = game->saved_mirror_portal.srcdmap;
10223 int32_t sourcescr = currscr, sourcedmap = currdmap;
10224 zfix tx = x, ty = y, tz = z;
10225 game->saved_mirror_portal.srcdmap = -1;
10226 action = none; FFCore.setHeroAction(none);
10227
10228 //Warp to new dmap
10229 FFCore.warp_player(wtIWARP, destdmap, destscr, -1, -1, mirror.misc1,
10230 mirror.usesound, 0, -1);
10231
10232 //Check for valid landing location
10233 if(mirrorBonk()) //Invalid landing, warp back!
10234 {
10235 action = none; FFCore.setHeroAction(none);
10236 lastentrance = tLastEntrance;
10237 lastentrance_dmap = tLastEntranceDMap;
10238 game->set_continue_scrn(tContScr);
10239 game->set_continue_dmap(tContDMap);
10240 x = tx;
10241 y = ty;
10242 z = tz;
10243 game->saved_mirror_portal.srcdmap = tPortalDMap;
10244 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, mirror.misc1,
10245 mirror.usesound, 0, -1);
10246 }
10247 else if(mirror.flags & ITEM_FLAG1) //Place portal!
10248 {
10249 //Place the portal
10250 game->set_portal(sourcedmap, destdmap, offscr, x.getZLong(), y.getZLong(), mirror.usesound, mirror.misc1, mirror.wpn);
10251 //Since it was placed after loading this screen, load the portal object now
10252 game->load_portal();
10253 //Don't immediately trigger the warp back
10254 mirror_portal.prox_active = false;
10255
10256 //Set continue point
10257 if(currdmap != game->get_continue_dmap())
10258 {
10259 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
10260 }
10261 game->set_continue_dmap(currdmap);
10262 lastentrance_dmap = currdmap;
10263 lastentrance = game->get_continue_scrn();
10264 }
10265 }
10266 }
10267
10268 6419576 void HeroClass::handle_passive_buttons()
10269 {
10270 6419576 do_liftglove(-1,true);
10271 6419576 do_jump(-1,true);
10272 6419576 }
10273
10274 static bool did_passive_jump = false;
10275 6419668 bool HeroClass::do_jump(int32_t jumpid, bool passive)
10276 {
10277
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 6419576 times.
6419668 if(passive) did_passive_jump = false;
10278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 else if(did_passive_jump) return false; //don't jump twice in the same frame
10279
10280
2/2
✓ Branch 0 taken 224741 times.
✓ Branch 1 taken 6194927 times.
6419668 if(nomove_action(action)) return false; //can't jump while ex. drowning
10281
2/2
✓ Branch 0 taken 50683 times.
✓ Branch 1 taken 6144244 times.
6194927 if(onWater(true)) return false; //Don't allow jumping off of water frame-perfectly...
10282
10283
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 6144152 times.
6144244 if(jumpid < 0)
10284 6144152 jumpid = current_item_id(itype_rocs,true,true);
10285
10286
2/2
✓ Branch 0 taken 5951910 times.
✓ Branch 1 taken 192334 times.
6144244 if(unsigned(jumpid) >= MAXITEMS) return false;
10287
4/4
✓ Branch 0 taken 192223 times.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 1411 times.
✓ Branch 3 taken 190812 times.
192334 if(inlikelike || charging) return false;
10288
1/2
✓ Branch 0 taken 190812 times.
✗ Branch 1 not taken.
190812 if(!checkitem_jinx(jumpid)) return false;
10289
10290 190812 itemdata const& itm = itemsbuf[jumpid];
10291
10292 190812 bool standing = isStanding(true);
10293
3/4
✓ Branch 0 taken 187766 times.
✓ Branch 1 taken 3046 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3046 times.
190812 bool coyotejump = !standing && coyotetime < (zc_min(65535,itm.misc5));
10294
4/6
✓ Branch 0 taken 190812 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3046 times.
✓ Branch 3 taken 187766 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3046 times.
190812 if(!(coyotejump || standing || extra_jump_count < itm.misc1)) return false;
10295
3/4
✓ Branch 0 taken 185964 times.
✓ Branch 1 taken 1802 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 185964 times.
187766 if(!(checkbunny(jumpid) && checkmagiccost(jumpid)))
10296 {
10297 1802 item_error();
10298 1802 return false;
10299 }
10300
10301 185964 byte intbtn = byte(itm.misc2&0xFF);
10302
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 185885 times.
185964 if(passive)
10303 {
10304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185885 times.
185885 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10305 185885 return false; //not pressed
10306 }
10307
10308 79 paymagiccost(jumpid);
10309
10310
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!standing)
10311 {
10312 ++extra_jump_count;
10313 fall = 0;
10314 fakefall = 0;
10315 if(hoverclk > 0)
10316 hoverclk = -hoverclk;
10317 }
10318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(itm.flags & ITEM_FLAG1)
10319 setFall(fall - itm.power);
10320 79 else setFall(fall - (FEATHERJUMP*(itm.power+2)));
10321 79 coyotetime = 65535; //jumped, so no coyotetime
10322 79 setOnSideviewLadder(false);
10323
10324 // Reset the ladder, unless on an unwalkable combo
10325
3/10
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 79 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 79 times.
✗ Branch 9 not taken.
79 if((ladderx || laddery) && !(_walkflag(ladderx,laddery,0,SWITCHBLOCK_STATE)))
10326 reset_ladder();
10327
10328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(itm.usesound)
10329 79 sfx(itm.usesound,pan(x.getInt()));
10330
10331
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(passive)
10332 {
10333 did_passive_jump = true;
10334 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10335 }
10336 79 return true;
10337 6419668 }
10338 863 void HeroClass::drop_liftwpn()
10339 {
10340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 863 times.
863 if(!lift_wpn) return;
10341
10342 handle_lift(false); //sets position properly, accounting for large weapons
10343 auto liftid = current_item_id(itype_liftglove,true,true);
10344 itemdata const& glove = itemsbuf[liftid];
10345 auto lheight = liftheight+z+fakez;
10346 if(glove.flags & ITEM_FLAG1)
10347 {
10348 lift_wpn->z = 0;
10349 lift_wpn->fakez = lheight;
10350 }
10351 else lift_wpn->z = lheight;
10352 lift_wpn->dir = dir;
10353 lift_wpn->step = 0;
10354 lift_wpn->fakefall = 0;
10355 lift_wpn->fall = 0;
10356 if(glove.flags & ITEM_FLAG1)
10357 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
10358 else
10359 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10360 Lwpns.add(lift_wpn);
10361 lift_wpn = nullptr;
10362 863 }
10363 6419576 void HeroClass::do_liftglove(int32_t liftid, bool passive)
10364 {
10365
1/2
✓ Branch 0 taken 6419576 times.
✗ Branch 1 not taken.
6419576 if(liftid < 0)
10366 6419576 liftid = current_item_id(itype_liftglove,true,true);
10367
2/2
✓ Branch 0 taken 9811 times.
✓ Branch 1 taken 6409765 times.
6419576 if(!can_lift(liftid)) return;
10368 9811 itemdata const& glove = itemsbuf[liftid];
10369 9811 byte intbtn = byte(glove.misc1&0xFF);
10370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9811 times.
9811 if(passive)
10371 {
10372
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 9759 times.
9811 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10373 9759 return; //not pressed
10374 52 }
10375
10376 52 bool had_weapon = lift_wpn;
10377
10378
3/4
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
91 if(!(had_weapon || //Allow throwing while bunnied/don't charge magic for throwing
10379
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 2 times.
41 (checkbunny(liftid) && checkmagiccost(liftid))))
10380 {
10381 2 item_error();
10382 2 return;
10383 }
10384
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
50 if(glove.script!=0 && (item_doscript[liftid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
10385 return;
10386
10387 50 bool paidmagic = had_weapon; //don't pay to throw, only to lift
10388
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if(glove.script)
10389 {
10390 if(!paidmagic)
10391 {
10392 paidmagic = true;
10393 paymagiccost(liftid);
10394 }
10395
10396 ri = &(itemScriptData[liftid]);
10397 for ( int32_t q = 0; q < 1024; q++ )
10398 item_stack[liftid][q] = 0xFFFF;
10399 ri->Clear();
10400 item_doscript[liftid] = 1;
10401 itemscriptInitialised[liftid] = 0;
10402 ZScriptVersion::RunScript(SCRIPT_ITEM, glove.script, liftid);
10403
10404 bool has_weapon = lift_wpn;
10405 if(has_weapon != had_weapon) //Item action script changed the lift information
10406 {
10407 if(passive)
10408 {
10409 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10410 }
10411 return;
10412 }
10413 }
10414
10415
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 39 times.
50 if(lift_wpn)
10416 {
10417
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!paidmagic)
10418 {
10419 paidmagic = true;
10420 paymagiccost(liftid);
10421 }
10422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!liftclk)
10423 {
10424 //Throw the weapon!
10425 //hero's direction and position
10426 11 handle_lift(false); //sets position properly, accounting for large weapons
10427 11 auto lheight = liftheight+z+fakez;
10428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(glove.flags & ITEM_FLAG1)
10429 {
10430 lift_wpn->z = 0;
10431 lift_wpn->fakez = lheight;
10432 }
10433 11 else lift_wpn->z = lheight;
10434 11 lift_wpn->dir = dir;
10435 //Configured throw speed in both axes
10436 11 lift_wpn->step = zfix(glove.misc2)/100;
10437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(glove.flags & ITEM_FLAG1)
10438 {
10439 lift_wpn->fakefall = -glove.misc3;
10440 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
10441 }
10442 else
10443 {
10444 11 lift_wpn->fall = -glove.misc3;
10445 11 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10446 }
10447 11 Lwpns.add(lift_wpn);
10448 11 lift_wpn = nullptr;
10449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(glove.usesound2)
10450 11 sfx(glove.usesound2,pan(int32_t(x)));
10451 11 }
10452
10453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(passive)
10454 {
10455 11 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10456 11 }
10457 11 return;
10458 }
10459
10460 39 bool lifted = false;
10461 //Check for a liftable weapon
10462 //if(!lifted)
10463 {
10464 39 zfix hx, hy, hw, hh;
10465
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 13 times.
39 switch(dir)
10466 {
10467 case up:
10468 15 hx = x;
10469 15 hy = y-8;
10470 15 hw = 16;
10471 15 hh = bigHitbox ? 8 : 16;
10472 15 break;
10473 case down:
10474 7 hx = x;
10475 7 hy = y+16;
10476 7 hw = 16;
10477 7 hh = 8;
10478 7 break;
10479 case left:
10480 4 hx = x-8;
10481 4 hy = y;
10482 4 hw = 8;
10483 4 hh = 16;
10484 4 break;
10485 case right:
10486 13 hx = x+16;
10487 13 hy = y;
10488 13 hw = 8;
10489 13 hh = 16;
10490 13 break;
10491 }
10492
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 16 times.
55 for(int32_t q = 0; q < Lwpns.Count(); ++q)
10493 {
10494 16 weapon* w = (weapon*)Lwpns.spr(q);
10495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 switch(w->id)
10496 {
10497 case wLitBomb:
10498 case wLitSBomb:
10499 if(w->parentitem>=0)
10500 {
10501 itemdata const& parent = itemsbuf[w->parentitem];
10502 if((parent.family==itype_bomb || parent.family==itype_sbomb)
10503 && (parent.misc4 && parent.misc4 <= glove.fam_type))
10504 {
10505 if(!w->hit(hx,hy,0,hw,hh,1))
10506 continue;
10507 lift(w, parent.misc5, parent.misc6);
10508 Lwpns.remove(w);
10509 lifted = true;
10510 break;
10511 }
10512 }
10513 break;
10514 }
10515
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(lifted) break;
10516 16 }
10517 }
10518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(!lifted) //Check for a liftable combo
10519 {
10520 39 zfix bx, by;
10521 39 zfix bx2, by2;
10522
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 13 times.
39 switch(dir)
10523 {
10524 case up:
10525 15 by = y + (bigHitbox ? -2 : 6);
10526 15 by2 = by;
10527 15 bx = x + 4;
10528 15 bx2 = bx + 8;
10529 15 break;
10530 case down:
10531 7 by = y + 17;
10532 7 by2 = by;
10533 7 bx = x + 4;
10534 7 bx2 = bx + 8;
10535 7 break;
10536 case left:
10537 4 by = y + (bigHitbox ? 0 : 8);
10538 4 by2 = y + 8;
10539 4 bx = x - 2;
10540 4 bx2 = x - 2;
10541 4 break;
10542 case right:
10543 13 by = y + (bigHitbox ? 0 : 8);
10544 13 by2 = y + 8;
10545 13 bx = x + 17;
10546 13 bx2 = x + 17;
10547 13 break;
10548 }
10549 39 int32_t pos = COMBOPOS_B(bx,by);
10550 39 int32_t pos2 = COMBOPOS_B(bx2,by2);
10551 39 int32_t foundpos = -1;
10552
10553
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 269 times.
297 for(auto lyr = 6; lyr >= 0; --lyr)
10554 {
10555 269 mapscr* scr = FFCore.tempScreens[lyr];
10556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 269 times.
269 if(pos > -1)
10557 {
10558 269 newcombo const& cmb = combobuf[scr->data[pos]];
10559
2/2
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 11 times.
269 if(cmb.liftflags & LF_LIFTABLE)
10560 {
10561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(do_lift_combo(lyr,pos,liftid))
10562 {
10563 11 lifted = true;
10564 11 break;
10565 }
10566 }
10567 258 }
10568
3/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 181 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
258 if(pos != pos2 && pos2 > -1)
10569 {
10570 77 newcombo const& cmb2 = combobuf[scr->data[pos2]];
10571
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(cmb2.liftflags & LF_LIFTABLE)
10572 {
10573 if(do_lift_combo(lyr,pos2,liftid))
10574 {
10575 lifted = true;
10576 break;
10577 }
10578 }
10579 77 }
10580 258 }
10581 39 }
10582
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 28 times.
39 if(!lifted) return;
10583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!paidmagic)
10584 {
10585 11 paidmagic = true;
10586 11 paymagiccost(liftid);
10587 11 }
10588 11 set_liftflags(liftid);
10589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(passive)
10590 11 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10591 11 return;
10592 6419576 }
10593 947 void HeroClass::handle_lift(bool dec)
10594 {
10595
1/2
✓ Branch 0 taken 947 times.
✗ Branch 1 not taken.
947 if(lift_wpn)
10596 947 lift_wpn->fakez = 0;
10597 else liftclk = 0;
10598
2/2
✓ Branch 0 taken 729 times.
✓ Branch 1 taken 218 times.
947 if(liftclk <= (dec?1:0))
10599 {
10600 729 liftclk = 0;
10601 729 tliftclk = 0;
10602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 729 times.
729 if(lift_wpn)
10603 {
10604
2/4
✓ Branch 0 taken 729 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 729 times.
729 if(lift_wpn->txsz > 1 || lift_wpn->tysz > 1)
10605 {
10606 lift_wpn->x = x+8 - (lift_wpn->txsz*8);
10607 lift_wpn->y = y+8 - (lift_wpn->tysz*8);
10608 }
10609 else
10610 {
10611 729 lift_wpn->x = x;
10612 729 lift_wpn->y = y;
10613 }
10614 729 lift_wpn->z = liftheight;
10615 729 }
10616
2/2
✓ Branch 0 taken 718 times.
✓ Branch 1 taken 11 times.
729 if(action == lifting)
10617 {
10618 11 action = none; FFCore.setHeroAction(none);
10619 11 }
10620 729 return;
10621 }
10622
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 109 times.
218 if(dec) --liftclk;
10623 double xdist, ydist;
10624 218 double perc = (liftclk/double(tliftclk));
10625
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 60 times.
✓ Branch 4 taken 70 times.
218 switch(dir)
10626 {
10627 case up:
10628 {
10629 14 xdist = 0;
10630 14 ydist = -16;
10631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(lift_wpn->txsz > 1)
10632 {
10633 xdist = -((lift_wpn->txsz*8)-8);
10634 }
10635 14 else xdist = 0;
10636
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(lift_wpn->tysz > 1)
10637 {
10638 ydist = -(lift_wpn->tysz*16);
10639 }
10640 14 ydist *= perc;
10641 14 break;
10642 }
10643 case down:
10644 {
10645 74 xdist = 0;
10646 74 ydist = 16;
10647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(lift_wpn->txsz > 1)
10648 {
10649 xdist = -((lift_wpn->txsz*8)-8);
10650 }
10651 74 else xdist = 0;
10652 74 ydist *= perc;
10653 74 break;
10654 }
10655 case left:
10656 {
10657 60 xdist = -16;
10658 60 ydist = 0;
10659
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(lift_wpn->txsz > 1)
10660 {
10661 xdist = -(lift_wpn->txsz*16);
10662 }
10663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(lift_wpn->tysz > 1)
10664 {
10665 ydist = -((lift_wpn->tysz*8)-8);
10666 }
10667 60 else ydist = 0;
10668 60 xdist *= perc;
10669 60 break;
10670 }
10671 case right:
10672 {
10673 70 xdist = 16;
10674 70 ydist = 0;
10675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(lift_wpn->tysz > 1)
10676 {
10677 ydist = -((lift_wpn->tysz*8)-8);
10678 }
10679 70 else ydist = 0;
10680 70 xdist *= perc;
10681 70 break;
10682 }
10683 }
10684
10685 218 lift_wpn->x = x + xdist;
10686 218 lift_wpn->y = y + ydist;
10687 218 lift_wpn->z = liftheight*(1.0-perc);
10688 947 }
10689 6419587 bool HeroClass::can_lift(int32_t gloveid)
10690 {
10691
2/2
✓ Branch 0 taken 6408621 times.
✓ Branch 1 taken 10966 times.
6419587 if(unsigned(gloveid) >= MAXITEMS) return false;
10692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10966 times.
10966 if(lstunclock) return false;
10693
1/2
✓ Branch 0 taken 10966 times.
✗ Branch 1 not taken.
10966 if(!checkitem_jinx(gloveid)) return false;
10694 10966 itemdata const& glove = itemsbuf[gloveid];
10695
2/3
✓ Branch 0 taken 1144 times.
✓ Branch 1 taken 9822 times.
✗ Branch 2 not taken.
10966 switch(action)
10696 {
10697 case none: case walking:
10698 9822 break;
10699
10700 case swimming:
10701 if(glove.flags & ITEM_FLAG2)
10702 break;
10703 return false;
10704
10705 default:
10706 1144 return false;
10707 }
10708 9822 return true;
10709 6419587 }
10710 11 void HeroClass::lift(weapon* w, byte timer, zfix height)
10711 {
10712 11 lift_wpn = w;
10713 11 liftclk = timer;
10714 11 tliftclk = timer;
10715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(height < 0)
10716 liftheight = 0;
10717 11 else liftheight = height;
10718 11 }
10719
10720 1 void HeroClass::doSwitchHook(byte style)
10721 {
10722 1 hs_switcher = true;
10723 1 pull_hero = true;
10724 //{ Load hook weapons, set them to obey special drawing
10725 1 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
10726 1 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
10727
10728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(w)
10729 1 w->switch_hooked = true;
10730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(hw)
10731 1 hw->switch_hooked = true;
10732
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for(int32_t j=0; j<chainlinks.Count(); j++)
10733 {
10734 5 chainlinks.spr(j)->switch_hooked = true;
10735 5 }
10736 //}
10737
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(hooked_combopos > -1)
10738 {
10739 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
10740 hooked_layerbits = 0;
10741 for(auto q = 0; q < 7; ++q)
10742 hooked_undercombos[q] = -1;
10743 uint16_t plpos = COMBOPOS(x+8,y+8);
10744 for(auto q = max_layer; q > -1; --q)
10745 {
10746 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[hooked_combopos]];
10747 newcombo const& comb2 = combobuf[FFCore.tempScreens[q]->data[plpos]];
10748 int32_t fl1 = FFCore.tempScreens[q]->sflag[hooked_combopos],
10749 fl2 = FFCore.tempScreens[q]->sflag[plpos];
10750 bool isPush = false;
10751 if(isSwitchHookable(cmb))
10752 {
10753 if(cmb.type == cSWITCHHOOK)
10754 {
10755 uint16_t plpos = COMBOPOS(x+8,y+8);
10756 if((cmb.usrflags&cflag1) && FFCore.tempScreens[q]->data[plpos])
10757 continue; //don't swap with non-zero combo
10758 if(zc_max(1,itemsbuf[(w && w->parentitem>-1) ? w->parentitem : current_item_id(itype_switchhook)].fam_type) < cmb.attribytes[0])
10759 continue; //too low a switchhook level
10760 hooked_layerbits |= 1<<q; //Swapping
10761 if(cmb.usrflags&cflag3)
10762 {
10763 if(cmb.usrflags&cflag6)
10764 {
10765 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
10766 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
10767 }
10768 else
10769 {
10770 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
10771 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
10772 }
10773 }
10774 else
10775 {
10776 hooked_layerbits |= 1<<(q+8); //Swapping BACK
10777 if(cmb.usrflags&cflag7) //counts as 'pushblock'
10778 isPush = true;
10779 }
10780 }
10781 else if(isCuttableType(cmb.type))
10782 {
10783 if(isCuttableNextType(cmb.type))
10784 {
10785 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
10786 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
10787 }
10788 else
10789 {
10790 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
10791 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
10792 }
10793 hooked_layerbits |= 1<<q; //Swapping
10794 }
10795 else
10796 {
10797 hooked_layerbits |= 1<<q; //Swapping
10798 hooked_layerbits |= 1<<(q+8); //Swapping BACK
10799 }
10800 }
10801 if(hooked_layerbits & (1<<(q+8))) //2-way swap, check for pushblocks
10802 {
10803 if((cmb.type==cPUSH_WAIT || cmb.type==cPUSH_HW || cmb.type==cPUSH_HW2)
10804 && hasMainGuy())
10805 {
10806 hooked_layerbits &= ~(0x101<<q); //Can't swap yet
10807 continue;
10808 }
10809 if(fl1 == mfPUSHED)
10810 {
10811 hooked_layerbits &= ~(0x101<<q); //Can't swap at all, locked in place
10812 continue;
10813 }
10814 if(!isPush) switch(fl1)
10815 {
10816 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
10817 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
10818 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
10819 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
10820 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
10821 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
10822 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
10823 isPush = true;
10824 }
10825 if(!isPush) switch(cmb.flag)
10826 {
10827 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
10828 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
10829 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
10830 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
10831 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
10832 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
10833 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
10834 isPush = true;
10835 }
10836 if(isPush) //Check for block holes / triggers
10837 {
10838 if(comb2.flag == mfBLOCKHOLE || fl2 == mfBLOCKHOLE
10839 || comb2.flag == mfBLOCKTRIGGER || fl2 == mfBLOCKTRIGGER)
10840 {
10841 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10842 }
10843 else if(!get_bit(quest_rules, qr_BLOCKHOLE_SAME_ONLY))
10844 {
10845 auto maxLayer = get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2) ? 2 : 0;
10846 for(auto lyr = 0; lyr < maxLayer; ++lyr)
10847 {
10848 if(lyr == q) continue;
10849 switch(FFCore.tempScreens[q]->sflag[plpos])
10850 {
10851 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
10852 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10853 lyr=7;
10854 break;
10855 }
10856 switch(combobuf[FFCore.tempScreens[q]->data[plpos]].flag)
10857 {
10858 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
10859 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10860 lyr=7;
10861 break;
10862 }
10863 }
10864 }
10865 }
10866 }
10867 }
10868 }
10869 1 switch_hooked = true;
10870 1 switchhookstyle = style;
10871
1/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 switch(style)
10872 {
10873 default: case swPOOF:
10874 {
10875 1 wpndata const& spr = wpnsbuf[QMisc.sprites[sprSWITCHPOOF]];
10876
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 switchhookmaxtime = switchhookclk = zc_max(spr.frames,1) * zc_max(spr.speed,1);
10877
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 decorations.add(new comboSprite(x, y, 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(hooked_combopos > -1)
10879 decorations.add(new comboSprite((zfix)COMBOX(hooked_combopos), (zfix)COMBOY(hooked_combopos), 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(switching_object)
10881
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 decorations.add(new comboSprite(switching_object->x, switching_object->y, 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10882 1 break;
10883 }
10884 case swFLICKER:
10885 {
10886 switchhookmaxtime = switchhookclk = 64;
10887 break;
10888 }
10889 case swRISE:
10890 {
10891 switchhookmaxtime = switchhookclk = 64;
10892 break;
10893 }
10894 }
10895 1 }
10896
10897 28432 bool HeroClass::startwpn(int32_t itemid)
10898 {
10899
2/2
✓ Branch 0 taken 265 times.
✓ Branch 1 taken 28167 times.
28432 if(itemid < 0) return false;
10900 28167 itemdata const& itm = itemsbuf[itemid];
10901
5/6
✓ Branch 0 taken 6832 times.
✓ Branch 1 taken 21335 times.
✓ Branch 2 taken 5381 times.
✓ Branch 3 taken 15954 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 51 times.
28218 if(((dir==up && y<24) || (dir==down && y>128) ||
10902
6/6
✓ Branch 0 taken 7801 times.
✓ Branch 1 taken 8153 times.
✓ Branch 2 taken 8149 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 28112 times.
28167 (dir==left && x<32) || (dir==right && x>208)) && !(get_bit(quest_rules,qr_ITEMSONEDGES) || inlikelike))
10903 51 return false;
10904
10905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28116 times.
28116 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
10906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28116 times.
28116 if(liftonly)
10907 {
10908 dowpn = -1;
10909 switch(itm.family)
10910 {
10911 case itype_bomb:
10912 case itype_sbomb:
10913 if(itm.flags & ITEM_FLAG4)
10914 do_liftglove(-1,false);
10915 break;
10916 case itype_liftglove:
10917 do_liftglove(-1,false);
10918 break;
10919 }
10920 return false;
10921 }
10922
10923 28116 int32_t wx=x;
10924 28116 int32_t wy=y-fakez;
10925 28116 int32_t wz=z;
10926 28116 bool ret = true;
10927
10928
5/5
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 6819 times.
✓ Branch 2 taken 5369 times.
✓ Branch 3 taken 7783 times.
✓ Branch 4 taken 8141 times.
28116 switch(dir)
10929 {
10930 case up:
10931 6819 wy-=16;
10932 6819 break;
10933
10934 case down:
10935 5369 wy+=16;
10936 5369 break;
10937
10938 case left:
10939 7783 wx-=16;
10940 7783 break;
10941
10942 case right:
10943 8141 wx+=16;
10944 8141 break;
10945 }
10946
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 28116 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
28116 if (IsSideSwim() && (itm.flags & ITEM_SIDESWIM_DISABLED)) return false;
10947
10948
15/27
✗ Branch 0 not taken.
✓ Branch 1 taken 225 times.
✓ Branch 2 taken 1163 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 92 times.
✓ Branch 9 taken 4 times.
✓ Branch 10 taken 185 times.
✓ Branch 11 taken 718 times.
✓ Branch 12 taken 15 times.
✓ Branch 13 taken 1535 times.
✓ Branch 14 taken 13280 times.
✓ Branch 15 taken 1077 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 823 times.
✓ Branch 18 taken 10 times.
✓ Branch 19 taken 8962 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 4 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
28116 switch(itm.family)
10949 {
10950 case itype_liftglove:
10951 {
10952 do_liftglove(itemid,false);
10953 dowpn = -1;
10954 ret = false;
10955 break;
10956 }
10957 case itype_potion:
10958 {
10959
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
23 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
10960 {
10961 return item_error();
10962 }
10963
10964 23 paymagiccost(itemid);
10965
10966
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23 if(itm.misc1 || itm.misc2)
10967 {
10968 23 refill_what=REFILL_ALL;
10969 23 refill_why=itemid;
10970 23 StartRefill(REFILL_ALL);
10971 23 potion_life = game->get_life();
10972 23 potion_magic = game->get_magic();
10973
10974 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
10975 //music_pause();
10976 23 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
10977
2/2
✓ Branch 0 taken 4932 times.
✓ Branch 1 taken 23 times.
4955 while(refill())
10978 {
10979 4932 do_refill_waitframe();
10980 }
10981
10982 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
10983 //music_resume();
10984 23 ret = false;
10985 23 }
10986
10987 23 break;
10988 }
10989 case itype_bottle:
10990 {
10991 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
10992 {
10993 return item_error();
10994 }
10995 if(itm.script!=0 && (item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
10996 return false;
10997
10998 size_t bind = game->get_bottle_slot(itm.misc1);
10999 bool paidmagic = false;
11000 if(itm.script)
11001 {
11002 paidmagic = true;
11003 paymagiccost(itemid);
11004
11005 ri = &(itemScriptData[itemid]);
11006 for ( int32_t q = 0; q < 1024; q++ )
11007 item_stack[itemid][q] = 0xFFFF;
11008 ri->Clear();
11009 item_doscript[itemid] = 1;
11010 itemscriptInitialised[itemid] = 0;
11011 ZScriptVersion::RunScript(SCRIPT_ITEM, itm.script, itemid);
11012 bind = game->get_bottle_slot(itm.misc1);
11013 }
11014 bottletype const* bt = bind ? &(QMisc.bottle_types[bind-1]) : NULL;
11015 if(bt)
11016 {
11017 word toFill[3] = { 0 };
11018 for(size_t q = 0; q < 3; ++q)
11019 {
11020 char c = bt->counter[q];
11021 if(c > -1)
11022 {
11023 if(bt->flags & (1<<q))
11024 {
11025 toFill[q] = (bt->amount[q]==100)
11026 ? game->get_maxcounter(c)
11027 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
11028 }
11029 else toFill[q] = bt->amount[q];
11030 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
11031 {
11032 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
11033 }
11034 }
11035 }
11036 word max = std::max(toFill[0], std::max(toFill[1], toFill[2]));
11037 bool run = max > 0;
11038 if(get_bit(quest_rules, qr_NO_BOTTLE_IF_ANY_COUNTER_FULL))
11039 run = ((bt->counter[0] > -1 && !toFill[0]) || (bt->counter[1] > -1 && !toFill[1]) || (bt->counter[2] > -1 && !toFill[2]));
11040 else
11041 {
11042 if((bt->flags & BTFLAG_CURESWJINX) && swordclk)
11043 run = true;
11044 else if((bt->flags & BTFLAG_CUREITJINX) && itemclk)
11045 run = true;
11046 }
11047 if(run || (bt->flags&BTFLAG_ALLOWIFFULL))
11048 {
11049 if(bt->flags & BTFLAG_CURESWJINX)
11050 {
11051 swordclk = 0;
11052 verifyAWpn();
11053 }
11054 if(bt->flags & BTFLAG_CUREITJINX)
11055 itemclk = 0;
11056 if(!paidmagic)
11057 paymagiccost(itemid);
11058 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
11059 sfx(itm.usesound,pan(x.getInt()));
11060 for(size_t q = 0; q < 20; ++q)
11061 do_refill_waitframe();
11062 double inc = max/60.0; //1 second
11063 double xtra[3]{ 0 };
11064 for(size_t q = 0; q < 60; ++q)
11065 {
11066 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
11067 sfx(QMisc.miscsfx[sfxREFILL]);
11068 for(size_t j = 0; j < 3; ++j)
11069 {
11070 xtra[j] += inc;
11071 word f = floor(xtra[j]);
11072 xtra[j] -= f;
11073 if(toFill[j] > f)
11074 {
11075 toFill[j] -= f;
11076 game->change_counter(f,bt->counter[j]);
11077 }
11078 else if(toFill[j])
11079 {
11080 game->change_counter(toFill[j],bt->counter[j]);
11081 toFill[j] = 0;
11082 }
11083 }
11084 do_refill_waitframe();
11085 }
11086 for(size_t j = 0; j < 3; ++j)
11087 {
11088 if(toFill[j])
11089 {
11090 game->change_counter(toFill[j],bt->counter[j]);
11091 toFill[j] = 0;
11092 }
11093 }
11094 for(size_t q = 0; q < 20; ++q)
11095 do_refill_waitframe();
11096 game->set_bottle_slot(itm.misc1, bt->next_type);
11097 }
11098 }
11099
11100 dowpn = -1;
11101 ret = false;
11102 break;
11103 }
11104
11105 case itype_note:
11106 {
11107 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11108 {
11109 return item_error();
11110 }
11111 if(!msg_active && itm.misc1 > 0 && itm.misc1 < MAXMSGS)
11112 {
11113 sfx(itm.usesound);
11114 donewmsg(itm.misc1);
11115 paymagiccost(itemid);
11116 }
11117 dowpn = -1;
11118 ret = false;
11119 break;
11120 }
11121
11122 case itype_mirror:
11123 doMirror(itemid);
11124 if(Quit)
11125 return false;
11126 ret = false;
11127 break;
11128
11129 case itype_rocs:
11130 {
11131
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 13 times.
92 if(!do_jump(itemid,false)) return false;
11132 79 ret = false;
11133 }
11134 79 break;
11135
11136 case itype_letter:
11137 {
11138
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 if(current_item(itype_letter)==i_letter &&
11139
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tmpscr[currscr<128?0:1].room==rP_SHOP &&
11140
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tmpscr[currscr<128?0:1].guy &&
11141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ((currscr<128&&!(DMaps[currdmap].flags&dmfGUYCAVES))
11142
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 ||(currscr>=128&&DMaps[currdmap].flags&dmfGUYCAVES)) &&
11143 4 checkbunny(itemid)
11144 )
11145 {
11146 4 int32_t usedid = getItemID(itemsbuf, itype_letter,i_letter+1);
11147
11148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(usedid != -1)
11149 4 getitem(usedid, true, true);
11150
11151 4 sfx(tmpscr[currscr<128?0:1].secretsfx);
11152 4 setupscreen();
11153 4 action=none; FFCore.setHeroAction(none);
11154 4 }
11155
11156 4 ret = false;
11157 }
11158 4 break;
11159
11160 case itype_whistle:
11161 {
11162 bool whistleflag;
11163
11164
4/4
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 177 times.
185 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11165 {
11166 8 return item_error();
11167 }
11168
11169 177 paymagiccost(itemid);
11170 177 sfx(itm.usesound);
11171
11172
4/4
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 78 times.
177 if(dir==up || dir==right)
11173 99 ++blowcnt;
11174 else
11175 78 --blowcnt;
11176
11177 177 int sfx_count = 0;
11178
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 32757 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 32761 times.
✓ Branch 6 taken 32580 times.
✓ Branch 7 taken 185 times.
32757 while ((!replay_is_active() && sfx_allocated(itm.usesound)) || (replay_is_active() && sfx_count < 180))
11179 {
11180 32580 sfx_count += 1;
11181 32580 advanceframe(true);
11182
11183
1/2
✓ Branch 0 taken 32580 times.
✗ Branch 1 not taken.
32580 if(Quit)
11184 return false;
11185 }
11186
11187
9/14
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 181 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 181 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 181 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 181 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 185 times.
✓ Branch 13 taken 4 times.
185 Lwpns.add(new weapon(x,y-fakez,z,wWhistle,0,0,dir,itemid,getUID(),false,0,1,0));
11188
11189
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 17 times.
185 if((whistleflag=findentrance(x,y,mfWHISTLE,get_bit(quest_rules, qr_PERMANENT_WHISTLE_SECRETS))))
11190 17 didstuff |= did_whistle;
11191
11192
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 166 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 166 times.
185 if((didstuff&did_whistle && itm.flags&ITEM_FLAG1) || currscr>=128)
11193 19 return false;
11194
11195
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 162 times.
166 if(itm.flags&ITEM_FLAG1) didstuff |= did_whistle;
11196
11197
4/4
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 136 times.
166 if((tmpscr->flags&fWHISTLE) || (tmpscr->flags7 & fWHISTLEWATER)
11198
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 || (tmpscr->flags7&fWHISTLEPAL))
11199 {
11200 30 whistleclk=0; // signal to start drying lake or doing other stuff
11201 30 }
11202 else
11203 {
11204 136 int32_t where = itm.misc1;
11205
11206
1/2
✓ Branch 0 taken 136 times.
✗ Branch 1 not taken.
136 if(where>right) where=dir^1;
11207
11208
5/6
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 43 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 89 times.
225 if(((DMaps[currdmap].flags&dmfWHIRLWIND && TriforceCount()) || DMaps[currdmap].flags&dmfWHIRLWINDRET) &&
11209
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
93 itm.misc2 >= 0 && itm.misc2 <= 8 && !whistleflag)
11210
4/12
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 89 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 89 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 89 times.
✗ Branch 11 not taken.
178 Lwpns.add(new weapon((zfix)(where==left?zfix(240):where==right?zfix(0):x),
11211
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 89 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 89 times.
✗ Branch 9 not taken.
89 (zfix)(where==down?zfix(0):where==up?zfix(160):y),
11212
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 (zfix)0,
11213 wWind,
11214 0, //type
11215 0,
11216 89 where,
11217
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 itemid,getUID(),false,false,true,0)); //last arg is byte special, used to override type for wWind for now. -Z 18JULY2020
11218
11219 132 whistleitem=itemid;
11220 }
11221
11222 162 ret = false;
11223 }
11224 162 break;
11225
11226 case itype_bomb:
11227 {
11228 //Remote detonation
11229
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 713 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 717 times.
718 if(Lwpns.idCount(wLitBomb) >= zc_max(itm.misc2,1))
11230 {
11231 1 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
11232
11233
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 while(Lwpns.idCount(wLitBomb) && ew->misc == 0)
11234 {
11235 //If this ever needs a version check, in the future. -z
11236 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 ) )
11237 {
11238 if ( ew->power > 1 ) //Don't reduce 1 to 0. -Z
11239 ew->power *= 0.5; //Remote bombs were dealing double damage. -Z
11240 }
11241 ew->misc=50;
11242 ew->clk=ew->misc-3;
11243 ew->id=wBomb;
11244 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
11245 }
11246
11247 1 deselectbombs(false);
11248 1 return false;
11249 }
11250
11251
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 717 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
717 if((itm.flags & ITEM_FLAG4) && lift_wpn)
11252 {
11253 do_liftglove(-1,false); //Throw the already-held weapon
11254 return false;
11255 }
11256
2/4
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 717 times.
717 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11257 {
11258 return item_error();
11259 }
11260
11261 717 paymagiccost(itemid);
11262
11263
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if(itm.misc1>0) // If not remote bombs
11264 717 deselectbombs(false);
11265
11266
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 578 times.
717 if(isdungeon())
11267 {
11268
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 63 times.
578 wy=zc_max(wy,16);
11269 578 }
11270
11271
4/8
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 717 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 717 times.
✗ Branch 7 not taken.
1434 weapon* wpn = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitBomb,itm.fam_type,
11272
2/4
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 717 times.
✗ Branch 3 not taken.
717 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true);
11273 717 bool lifted = false;
11274
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if(itm.flags & ITEM_FLAG4)
11275 {
11276 auto liftid = current_item_id(itype_liftglove);
11277 itemdata const& glove = itemsbuf[liftid];
11278 if(liftid > -1 && (!itm.misc4 || itm.misc4 <= glove.fam_type))
11279 {
11280 lift(wpn,itm.misc5,itm.misc6);
11281 set_liftflags(liftid);
11282 lifted = true;
11283 }
11284 }
11285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 717 times.
717 if(!lifted)
11286 {
11287 717 Lwpns.add(wpn);
11288 717 sfx(WAV_PLACE,pan(wx));
11289 717 }
11290 }
11291 717 break;
11292
11293 case itype_sbomb:
11294 {
11295 //Remote detonation
11296
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 if(Lwpns.idCount(wLitSBomb) >= zc_max(itm.misc2,1))
11297 {
11298 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
11299
11300 while(Lwpns.idCount(wLitSBomb) && ew->misc == 0)
11301 {
11302 ew->misc=50;
11303 ew->clk=ew->misc-3;
11304 ew->id=wSBomb;
11305 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
11306 }
11307
11308 deselectbombs(true);
11309 return false;
11310 }
11311
11312
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15 if((itm.flags & ITEM_FLAG4) && lift_wpn)
11313 {
11314 do_liftglove(-1,false); //Throw the already-held weapon
11315 return false;
11316 }
11317
2/4
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11318 {
11319 return item_error();
11320 }
11321
11322 15 paymagiccost(itemid);
11323
11324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(itm.misc1>0) // If not remote bombs
11325 15 deselectbombs(true);
11326
11327
6/12
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
15 weapon* wpn = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitSBomb,itm.fam_type,itm.power*game->get_hero_dmgmult(),dir, itemid,getUID(),false,false,true);
11328 15 bool lifted = false;
11329
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(itm.flags & ITEM_FLAG4)
11330 {
11331 auto liftid = current_item_id(itype_liftglove);
11332 itemdata const& glove = itemsbuf[liftid];
11333 if(liftid > -1 && (!itm.misc4 || itm.misc4 <= glove.fam_type))
11334 {
11335 lift(wpn,itm.misc5,itm.misc6);
11336 set_liftflags(liftid);
11337 lifted = true;
11338 }
11339 }
11340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(!lifted)
11341 {
11342 15 Lwpns.add(wpn);
11343 15 sfx(WAV_PLACE,pan(wx));
11344 15 }
11345 }
11346 15 break;
11347
11348 case itype_wand:
11349 {
11350
2/2
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 1096 times.
1535 if(Lwpns.idCount(wMagic))
11351 {
11352 439 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11353 439 return false;
11354 }
11355
11356 1096 int32_t bookid = current_item_id(itype_book);
11357
3/4
✓ Branch 0 taken 653 times.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 653 times.
1096 bool paybook = (bookid>-1 && checkbunny(bookid) && checkmagiccost(bookid));
11358
11359
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1096 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1096 if(!(itm.flags&ITEM_FLAG1) && !paybook) //Can the wand shoot without the book?
11360 {
11361 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11362 return false;
11363 }
11364
11365
4/6
✓ Branch 0 taken 1096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1096 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1095 times.
✓ Branch 5 taken 1 times.
1096 if(!checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_WAND_COST || checkmagiccost(itemid)))
11366 {
11367 1 return item_error();
11368 }
11369
11370
2/2
✓ Branch 0 taken 1092 times.
✓ Branch 1 taken 3 times.
1095 if(Lwpns.idCount(wBeam))
11371 3 Lwpns.del(Lwpns.idFirst(wBeam));
11372
11373 int32_t type, pow;
11374
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 666 times.
1095 if ( get_bit(quest_rules,qr_BROKENBOOKCOST) )
11375 {
11376
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 79 times.
429 type = bookid != -1 ? current_item(itype_book) : itm.fam_type;
11377
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 79 times.
429 pow = (bookid != -1 ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11378 429 }
11379 else
11380 {
11381
3/4
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 363 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
666 type = (bookid != -1 && paybook) ? current_item(itype_book) : itm.fam_type;
11382
3/4
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 363 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
666 pow = ((bookid != -1 && paybook) ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11383 }
11384
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1095 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2190 times.
✓ Branch 4 taken 1095 times.
✓ Branch 5 taken 1095 times.
2190 for(int32_t i=(spins==1?up:dir); i<=(spins==1 ? right:dir); i++)
11385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1095 times.
2190 if(dir!=(i^1))
11386 {
11387
5/10
✓ Branch 0 taken 1095 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1095 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1095 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1095 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1095 times.
✗ Branch 9 not taken.
1095 weapon *magic = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wMagic,type,pow,i, itemid,getUID(),false,false,true);
11388
2/2
✓ Branch 0 taken 442 times.
✓ Branch 1 taken 653 times.
1095 if(paybook)
11389 653 magic->linkedItem = bookid;
11390 //magic->dir = this->dir; //Save player dir for special weapons.
11391 1095 Lwpns.add(magic);
11392 1095 }
11393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1095 times.
1095 if(!(misc_internal_hero_flags & LF_PAID_WAND_COST))
11394 1095 paymagiccost(itemid);
11395 else misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11396
11397
2/2
✓ Branch 0 taken 442 times.
✓ Branch 1 taken 653 times.
1095 if(paybook)
11398 653 paymagiccost(current_item_id(itype_book));
11399
11400
2/2
✓ Branch 0 taken 653 times.
✓ Branch 1 taken 442 times.
1095 if(bookid != -1)
11401 {
11402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 653 times.
653 if (( itemsbuf[bookid].flags & ITEM_FLAG4 ))
11403 {
11404 sfx(itemsbuf[bookid].misc2,pan(wx));
11405 }
11406 else
11407 {
11408 653 sfx(itm.usesound,pan(wx));
11409 }
11410 653 }
11411 else
11412 442 sfx(itm.usesound,pan(wx));
11413 }
11414 /*
11415 // Fireball Wand
11416 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wRefFireball,0,2*game->get_hero_dmgmult(),dir));
11417 switch (dir)
11418 {
11419 case up:
11420 Lwpns.spr(Lwpns.Count()-1)->angle=-PI/2;
11421 Lwpns.spr(Lwpns.Count()-1)->dir=up;
11422 break;
11423 case down:
11424 Lwpns.spr(Lwpns.Count()-1)->angle=PI/2;
11425 Lwpns.spr(Lwpns.Count()-1)->dir=down;
11426 break;
11427 case left:
11428 Lwpns.spr(Lwpns.Count()-1)->angle=PI;
11429 Lwpns.spr(Lwpns.Count()-1)->dir=left;
11430 break;
11431 case right:
11432 Lwpns.spr(Lwpns.Count()-1)->angle=0;
11433 Lwpns.spr(Lwpns.Count()-1)->dir=right;
11434 break;
11435 }
11436 Lwpns.spr(Lwpns.Count()-1)->clk=16;
11437 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step=3.5;
11438 Lwpns.spr(Lwpns.Count()-1)->dummy_bool[0]=true; //homing
11439 */
11440 1095 break;
11441
11442 case itype_sword:
11443 {
11444
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13280 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13280 if(!(checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_SWORD_COST || checkmagiccost(itemid))))
11445 {
11446 return item_error();
11447 }
11448
11449
4/4
✓ Branch 0 taken 2603 times.
✓ Branch 1 taken 10677 times.
✓ Branch 2 taken 2603 times.
✓ Branch 3 taken 10677 times.
13280 if((Lwpns.idCount(wBeam) && spins==0)||Lwpns.idCount(wMagic))
11450 {
11451 2603 misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
11452 2603 return false;
11453 }
11454
11455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10677 times.
10677 if(!(misc_internal_hero_flags & LF_PAID_SWORD_COST))//If already paid to use sword melee, don't charge again
11456 10677 paymagiccost(itemid);
11457 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
11458 float temppower;
11459
11460
1/2
✓ Branch 0 taken 10677 times.
✗ Branch 1 not taken.
10677 if(itm.flags & ITEM_FLAG2)
11461 {
11462 10677 temppower=game->get_hero_dmgmult()*itm.power;
11463 10677 temppower=temppower*itm.misc2;
11464 10677 temppower=temppower/100;
11465 10677 }
11466 else
11467 {
11468 temppower = game->get_hero_dmgmult()*itm.misc2;
11469 }
11470
11471 //Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID()));
11472 //Add weapon script to sword beams.
11473
5/10
✓ Branch 0 taken 10677 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10677 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10677 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10677 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 10677 times.
✗ Branch 9 not taken.
10677 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID(),false,false,true));
11474 //weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //the pointer to this beam
11475 //w->weaponscript = itm.weaponscript;
11476 //w->canrunscript = 0;
11477 10677 sfx(WAV_BEAM,pan(wx));
11478 }
11479 10677 break;
11480
11481 case itype_candle:
11482 {
11483 1077 int32_t countid = itemid;
11484
2/2
✓ Branch 0 taken 1049 times.
✓ Branch 1 taken 28 times.
1077 if(get_bit(quest_rules, qr_CANDLES_SHARED_LIMIT))
11485 1049 countid = -itype_candle;
11486
5/6
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 266 times.
✓ Branch 2 taken 266 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 1067 times.
1077 if(itm.flags&ITEM_FLAG1 && usecounts[countid] >= zc_max(1, itm.misc3))
11487 {
11488 10 return false;
11489 }
11490
11491
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1067 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 1004 times.
1067 if(Lwpns.idCount(wFire) >= (itm.misc2 < 1 ? 2 : itm.misc2))
11492 {
11493 63 return false;
11494 }
11495
11496
3/4
✓ Branch 0 taken 1004 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 996 times.
1004 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11497 {
11498 8 return item_error();
11499 }
11500
11501 996 paymagiccost(itemid);
11502
11503
2/2
✓ Branch 0 taken 748 times.
✓ Branch 1 taken 248 times.
996 if(itm.flags&ITEM_FLAG1) ++usecounts[countid];
11504
11505
4/8
✓ Branch 0 taken 996 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 996 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 996 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 996 times.
✗ Branch 7 not taken.
1992 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wFire,
11506 //(itm.fam_type > 1), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
11507 996 (itm.fam_type), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
11508
2/4
✓ Branch 0 taken 996 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 996 times.
✗ Branch 3 not taken.
996 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11509 996 sfx(itm.usesound,pan(wx));
11510 996 attack=wFire;
11511 }
11512 996 break;
11513
11514 case itype_script1: case itype_script2: case itype_script3: case itype_script4: case itype_script5:
11515 case itype_script6: case itype_script7: case itype_script8: case itype_script9: case itype_script10:
11516 {
11517 int32_t wtype = wScript1 + (itm.family-itype_script1);
11518 if(Lwpns.idCount(wtype))
11519 return false;
11520
11521 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11522 {
11523 return item_error();
11524 }
11525
11526 if(!get_bit(quest_rules, qr_CUSTOMWEAPON_IGNORE_COST))
11527 paymagiccost(itemid);
11528
11529 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wtype,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11530 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = itm.misc1/100;
11531 sfx(itm.usesound,pan(wx));
11532 }
11533 break;
11534
11535 case itype_icerod:
11536 {
11537 if(Lwpns.idCount(wIce))
11538 return false;
11539
11540 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11541 {
11542 return item_error();
11543 }
11544
11545 if(!get_bit(quest_rules, qr_CUSTOMWEAPON_IGNORE_COST))
11546 paymagiccost(itemid);
11547
11548 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wIce,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11549 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = itm.misc1/100;
11550 sfx(itm.usesound,pan(wx));
11551 }
11552 break;
11553
11554 case itype_arrow:
11555 {
11556
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 823 times.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 789 times.
823 if(Lwpns.idCount(wArrow) >= (itm.misc2 < 1 ? 1 : itm.misc2))
11557 34 return false;
11558
11559
2/4
✓ Branch 0 taken 789 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 789 times.
789 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11560 {
11561 return item_error();
11562 }
11563
11564 789 paymagiccost(itemid);
11565
11566
6/12
✓ Branch 0 taken 789 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 789 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 789 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 789 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 789 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 789 times.
✗ Branch 11 not taken.
789 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wArrow,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11567 789 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step*=(current_item_power(itype_bow)+1)/2;
11568 789 sfx(itm.usesound,pan(wx));
11569 }
11570 789 break;
11571
11572 case itype_bait:
11573 {
11574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(Lwpns.idCount(wBait)) //TODO: More than one Bait per screen?
11575 return false;
11576
11577
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
10 if(!checkbunny(itemid))
11578 3 return item_error();
11579
11580
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
14 bool grumble = (tmpscr->room==rGRUMBLE && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)));
11581
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 bool checkcost = grumble || !(itm.flags & ITEM_FLAG4);
11582
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 bool paycost = grumble || !(itm.flags & (ITEM_FLAG4|ITEM_FLAG5));
11583
11584
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 if(!grumble && (itm.flags & ITEM_FLAG2))
11585 return item_error(); //Only usable for grumble rooms
11586
11587
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7 if(checkcost && !checkmagiccost(itemid))
11588 return item_error();
11589
11590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(paycost)
11591 7 paymagiccost(itemid);
11592 7 sfx(itm.usesound,pan(wx));
11593
11594
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(grumble)
11595 {
11596
4/8
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
7 items.add(new item((zfix)wx,(zfix)wy,(zfix)0,itemid,ipDUMMY+ipFADE,0));
11597 7 fadeclk=66;
11598 7 dismissmsg();
11599 7 clear_bitmap(pricesdisplaybuf);
11600 7 set_clip_state(pricesdisplaybuf, 1);
11601 // putscr(scrollbuf,0,0,tmpscr);
11602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
11603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(!(itm.flags & ITEM_FLAG3)) //"Don't remove when feeding" flag
11604 {
11605 7 removeItemsOfFamily(game,itemsbuf,itype_bait);
11606 7 verifyBothWeapons();
11607 7 }
11608 7 sfx(tmpscr->secretsfx);
11609 7 return false;
11610 }
11611
11612 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBait,0,0,dir,itemid,getUID(),false,false,true));
11613 break;
11614 }
11615
11616 case itype_brang:
11617 {
11618
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 8673 times.
8962 if(Lwpns.idCount(wBrang) > itm.misc2)
11619 289 return false;
11620
11621
2/4
✓ Branch 0 taken 8673 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8673 times.
8673 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11622 {
11623 return item_error();
11624 }
11625
11626 8673 paymagiccost(itemid);
11627 8673 current_item_power(itype_brang);
11628
6/12
✓ Branch 0 taken 8673 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8673 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8673 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8673 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8673 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 8673 times.
✗ Branch 11 not taken.
8673 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBrang,itm.fam_type,(itm.power*game->get_hero_dmgmult()),dir,itemid,getUID(),false,false,true));
11629 }
11630 8673 break;
11631
11632 case itype_hookshot:
11633 case itype_switchhook:
11634 {
11635
2/4
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 225 times.
225 if(inlikelike || Lwpns.idCount(wHookshot))
11636 return false;
11637
11638
2/4
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 225 times.
225 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11639 {
11640 return item_error();
11641 }
11642 225 bool sw = itm.family == itype_switchhook;
11643
11644
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 223 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
225 if(sw && (itm.flags&ITEM_FLAG8))
11645 switchhook_cost_item = itemid;
11646 225 else paymagiccost(itemid);
11647
11648 225 bool use_hookshot=true;
11649 225 bool hit_hs = false, hit_solid = false, insta_switch = false;
11650
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 222 times.
225 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
11651 225 int32_t cpos = -1, ffcpos = -1;
11652
4/4
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 243 times.
✓ Branch 2 taken 243 times.
✓ Branch 3 taken 225 times.
468 for(int32_t i=0; i<=max_layer && !hit_hs; ++i)
11653 {
11654
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 49 times.
243 if(dir==up)
11655 {
11656
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 1 times.
49 if(check_hshot(i,x+2,y-7,sw, &cpos, &ffcpos))
11657 1 hit_hs = true;
11658 49 }
11659
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 155 times.
194 else if(dir==down)
11660 {
11661
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(check_hshot(i,x+12,y+23,sw, &cpos, &ffcpos))
11662 hit_hs = true;
11663 39 }
11664
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 89 times.
155 else if(dir==left)
11665 {
11666
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(check_hshot(i,x-7,y+12,sw, &cpos, &ffcpos))
11667 hit_hs = true;
11668 66 }
11669
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 else if(dir==right)
11670 {
11671
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(check_hshot(i,x+23,y+12,sw, &cpos, &ffcpos))
11672 hit_hs = true;
11673 89 }
11674 //Diagonal Hookshot (6)
11675 else if(dir==r_down)
11676 {
11677 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
11678 hit_hs = true;
11679 }
11680 else if(dir==l_down)
11681 {
11682 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
11683 hit_hs = true;
11684 }
11685 else if(dir==r_up)
11686 {
11687 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
11688 hit_hs = true;
11689 }
11690 else if(dir==l_up)
11691 {
11692 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
11693 hit_hs = true;
11694 }
11695 243 }
11696
8/10
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 49 times.
✓ Branch 6 taken 44 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 223 times.
✓ Branch 9 taken 2 times.
225 if(dir==up && _walkflag(x+2,y+4,1,SWITCHBLOCK_STATE) && !ishookshottable(x.getInt(),int32_t(y+4)))
11697 2 hit_solid = true;
11698
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 1 times.
225 if(hit_hs)
11699 {
11700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(sw)
11701 insta_switch = true; //switch immediately
11702 1 else use_hookshot = false; //No hooking against grabbable
11703 1 }
11704
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 223 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
225 if(hit_solid && !insta_switch)
11705 2 use_hookshot = false;
11706
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 222 times.
225 if(use_hookshot)
11707 {
11708 222 int32_t hookitem = itm.fam_type;
11709 222 int32_t hookpower = itm.power;
11710 222 byte allow_diagonal = (itm.flags & ITEM_FLAG2) ? 1 : 0;
11711
11712
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!Lwpns.has_space())
11713 {
11714 Lwpns.del(0);
11715 }
11716
11717
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!Lwpns.has_space(2))
11718 {
11719 Lwpns.del(0);
11720 }
11721
11722
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 54 times.
✓ Branch 4 taken 83 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
222 switch(dir)
11723 {
11724 case up:
11725 {
11726 46 hookshot_used=true;
11727 46 hs_switcher = sw;
11728
4/8
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 46 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 46 times.
✗ Branch 7 not taken.
92 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11729
2/4
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
46 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11730 46 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11731
5/10
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 46 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 46 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 46 times.
✗ Branch 9 not taken.
92 Lwpns.add(new weapon((zfix)wx,(zfix)wy-4,(zfix)wz,wHookshot,hookitem,
11732
2/4
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
46 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11733 46 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11734 46 hs_startx=wx;
11735 46 hs_starty=wy-4;
11736 }
11737 46 break;
11738
11739 case down:
11740 {
11741 39 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11742 39 hookshot_used=true;
11743 39 hs_switcher = sw;
11744
5/10
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 39 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 39 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 39 times.
✗ Branch 9 not taken.
78 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11745
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
39 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11746 39 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11747
5/10
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 39 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 39 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 39 times.
✗ Branch 9 not taken.
78 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11748
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
39 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11749 39 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11750 39 hs_startx=wx;
11751 39 hs_starty=wy;
11752 }
11753 39 break;
11754
11755 case left:
11756 {
11757 54 hookshot_used=true;
11758 54 hs_switcher = sw;
11759
4/8
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 54 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
108 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11760
2/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
54 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11761 54 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11762
4/8
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 54 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
108 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11763
2/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
54 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11764 54 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11765 54 hs_startx=wx-4;
11766 54 hs_starty=wy;
11767 }
11768 54 break;
11769
11770 case right:
11771 {
11772 83 hookshot_used=true;
11773 83 hs_switcher = sw;
11774
4/8
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 83 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 83 times.
✗ Branch 7 not taken.
166 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11775
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11776 83 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11777
4/8
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 83 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 83 times.
✗ Branch 7 not taken.
166 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11778
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11779 83 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11780 83 hs_startx=wx+4;
11781 83 hs_starty=wy;
11782 }
11783 83 break;
11784 //Diagonal Hookshot (7)
11785 case r_down:
11786 {
11787 hookshot_used=true;
11788 hs_switcher = sw;
11789 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11790 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11791 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11792 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11793 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11794 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11795 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11796 hs_startx=wx+4;
11797 hs_starty=wy;
11798 }
11799 break;
11800
11801 case r_up:
11802 {
11803 hookshot_used=true;
11804 hs_switcher = sw;
11805 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11806 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11807 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11808 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11809 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11810 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11811 hs_startx=wx+4;
11812 hs_starty=wy;
11813 }
11814 break;
11815
11816 case l_down:
11817 {
11818 hookshot_used=true;
11819 hs_switcher = sw;
11820 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11821 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11822 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11823 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11824 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11825 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11826 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11827 hs_startx=wx+4;
11828 hs_starty=wy;
11829 }
11830 break;
11831
11832 case l_up:
11833 {
11834 hookshot_used=true;
11835 hs_switcher = sw;
11836 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11837 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11838 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11839 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11840 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11841 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11842 hs_startx=wx+4;
11843 hs_starty=wy;
11844 }
11845 break;
11846 }
11847 222 hookshot_frozen=true;
11848 222 }
11849
1/2
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
225 if(insta_switch)
11850 {
11851 weapon* w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot));
11852 if (cpos > -1) hooked_combopos = cpos;
11853 if (ffcpos > -1)
11854 {
11855 switching_object = &(tmpscr->ffcs[ffcpos]);
11856 switching_object->switch_hooked = true;
11857 }
11858 w->misc=2;
11859 w->step=0;
11860 doSwitchHook(itm.misc5);
11861 if(itm.usesound2)
11862 sfx(itm.usesound2,pan(int32_t(x)));
11863 else if(QMisc.miscsfx[sfxSWITCHED])
11864 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
11865 stop_sfx(itm.usesound);
11866 }
11867 }
11868 225 break;
11869
11870 case itype_divinefire:
11871 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11872 return false;
11873
11874 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11875 {
11876 return item_error();
11877 }
11878
11879 paymagiccost(itemid);
11880 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11881 else {action=casting; FFCore.setHeroAction(casting);}
11882 magicitem=itemid;
11883 break;
11884
11885 case itype_divineescape:
11886 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11887 return false;
11888
11889 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11890 {
11891 return item_error();
11892 }
11893
11894 paymagiccost(itemid);
11895 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11896 else {action=casting; FFCore.setHeroAction(casting);}
11897 magicitem=itemid;
11898 break;
11899
11900 case itype_divineprotection:
11901 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11902 return false;
11903
11904 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11905 {
11906 return item_error();
11907 }
11908
11909 paymagiccost(itemid);
11910 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11911 else {action=casting; FFCore.setHeroAction(casting);}
11912 magicitem=itemid;
11913 break;
11914
11915 case itype_cbyrna:
11916 {
11917 //Beams already deployed
11918
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if(Lwpns.idCount(wCByrna))
11919 {
11920 2 stopCaneOfByrna();
11921 2 return false;
11922 }
11923
11924
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11925 {
11926 stop_sfx(itm.usesound); //if we can't pay the cost, kill the sound.
11927 //last_cane_of_byrna_item_id = -1; //no, we'd do this in a byrna cleanup function.
11928 return false;
11929 }
11930
11931 2 paymagiccost(itemid);
11932 2 last_cane_of_byrna_item_id = itemid;
11933 //zprint("itm.misc3: %d\n", itm.misc3);
11934
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 for(int32_t i=0; i<itm.misc3; i++)
11935 {
11936 //byrna weapons are added here
11937 //space them apart
11938 //zprint("Added byrna weapon %d.\n", i);
11939 //the iterator isn passed to 'type'. weapons.cpp converts thisd to
11940 //'quantity_iterator' pn construction; and this is used for orbit initial spacing.
11941
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
2 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11942 //Lwpns.add(new weapon((zfix)wx+cos(2 * PI / (i+1)),(zfix)wy+sin(2 * PI / (i+1)),(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11943 //wx += cos(2 * PI / (itm.misc3-i));
11944 //wy += sin(2 * PI / (itm.misc3-i));
11945 2 }
11946
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!(Lwpns.idCount(wCByrna)))
11947 stop_sfx(itm.usesound); //If we can't create the beams, kill the sound.
11948 }
11949 2 break;
11950
11951 case itype_clock:
11952 {
11953 ret = false;
11954 if(!(itm.flags & ITEM_FLAG1))
11955 break; //Passive clock, don't use
11956 if((itm.flags & ITEM_FLAG2) && watch) //"Can't activate while clock active"
11957 break;
11958 if(!(checkbunny(itemid) && checkmagiccost(itemid))) //cost/bunny check
11959 {
11960 return item_error();
11961 }
11962
11963 paymagiccost(itemid);
11964
11965 setClock(watch=true);
11966
11967 for(int32_t i=0; i<eMAXGUYS; i++)
11968 clock_zoras[i]=0;
11969
11970 clockclk=itm.misc1;
11971 sfx(itm.usesound);
11972 break;
11973 }
11974 case itype_killem:
11975 {
11976 ret = false;
11977 if(!(itm.flags & ITEM_FLAG1))
11978 break; //Passive killemall, don't use
11979
11980 if(!(checkbunny(itemid) && checkmagiccost(itemid))
11981 || !can_kill_em_all()) //No enemies onscreen
11982 {
11983 return item_error();
11984 }
11985
11986 paymagiccost(itemid);
11987
11988 kill_em_all();
11989 sfx(itm.usesound);
11990 break;
11991 }
11992 case itype_refill:
11993 {
11994 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11995 {
11996 return item_error();
11997 }
11998
11999 bool did_something = false;
12000
12001 if(itm.flags & ITEM_FLAG1) //Cure sword jinx
12002 {
12003 if(swordclk)
12004 did_something = true;
12005 swordclk = 0;
12006 verifyAWpn();
12007 }
12008 for(auto q = 0; q < 5; ++q)
12009 {
12010 auto ctr = itm.misc(q);
12011 if(unsigned(ctr) >= MAX_COUNTERS)
12012 continue;
12013 int16_t amnt = vbound(itm.misc(q+5),-32768,32767);
12014 if(!amnt) continue;
12015 bool gradual = itm.flags & ITEM_FLAG2;
12016 if(amnt > 0)
12017 {
12018 if(game->get_counter(ctr) + game->get_dcounter(ctr) >= game->get_maxcounter(ctr))
12019 {
12020 //Can't *do* anything... skip
12021 continue;
12022 }
12023 if(game->get_counter(ctr) >= game->get_maxcounter(ctr))
12024 {
12025 //Can't do anything unless affecting dcounter
12026 gradual = true;
12027 }
12028 }
12029 else //Negative
12030 {
12031 if(game->get_counter(ctr) + game->get_dcounter(ctr) <= 0)
12032 {
12033 //Can't *do* anything... skip
12034 continue;
12035 }
12036 if(game->get_counter(ctr) <= 0)
12037 {
12038 //Can't do anything unless affecting dcounter
12039 gradual = true;
12040 }
12041 }
12042 did_something = true;
12043 if(gradual) //Gradual
12044 {
12045 game->change_dcounter(amnt, ctr);
12046 }
12047 else
12048 {
12049 game->change_counter(amnt, ctr);
12050 }
12051 }
12052 if(!did_something)
12053 {
12054 return item_error();
12055 }
12056 paymagiccost(itemid);
12057 sfx(itm.usesound);
12058 ret = false;
12059 break;
12060 }
12061
12062 default:
12063 1163 ret = false;
12064 1163 }
12065
12066
2/2
✓ Branch 0 taken 24597 times.
✓ Branch 1 taken 23 times.
24620 if(itm.flags & ITEM_DOWNGRADE)
12067 {
12068 23 game->set_item(itemid,false);
12069
12070 // Maybe Item Override has allowed the same item in both slots?
12071
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(Bwpn == itemid)
12072 {
12073 Bwpn = 0;
12074 game->forced_bwpn = -1;
12075 verifyBWpn();
12076 }
12077
12078
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(Awpn == itemid)
12079 {
12080 Awpn = 0;
12081 game->forced_awpn = -1;
12082 verifyAWpn();
12083 }
12084
12085
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(Xwpn == itemid)
12086 {
12087 Xwpn = 0;
12088 game->forced_xwpn = -1;
12089 verifyXWpn();
12090 }
12091
12092
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(Ywpn == itemid)
12093 {
12094 Ywpn = 0;
12095 game->forced_ywpn = -1;
12096 verifyYWpn();
12097 }
12098 23 }
12099
12100 24620 return ret;
12101 28436 }
12102
12103
12104 886123 bool HeroClass::doattack()
12105 {
12106
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 886123 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
886123 if(lift_wpn && (liftflags & LIFTFL_DIS_ITEMS))
12107 return false;
12108 //int32_t s = BSZ ? 0 : 11;
12109 886123 int32_t s = (zinit.heroAnimationStyle==las_bszelda) ? 0 : 11;
12110
12111
3/4
✓ Branch 0 taken 31486 times.
✓ Branch 1 taken 854637 times.
✓ Branch 2 taken 31486 times.
✗ Branch 3 not taken.
886123 int32_t bugnetid = (directWpn>-1 && itemsbuf[directWpn].family==itype_bugnet) ? directWpn : current_item_id(itype_bugnet);
12112
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 886123 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
886123 if(attack==wBugNet && bugnetid!=-1)
12113 {
12114 if(++attackclk >= NET_CLK_TOTAL)
12115 return false;
12116
12117 return true;
12118 }
12119
12120 // Abort attack if attackclk has run out and:
12121 // * the attack is not Hammer, Sword with Spin Scroll, Candle, or Wand, OR
12122 // * you aren't holding down the A button, you're not charging, and/or you're still spinning
12123
12124
6/6
✓ Branch 0 taken 60795 times.
✓ Branch 1 taken 825328 times.
✓ Branch 2 taken 48526 times.
✓ Branch 3 taken 12269 times.
✓ Branch 4 taken 2287 times.
✓ Branch 5 taken 3601 times.
892011 if(attackclk>=(spins>0?8:14) && attack!=wHammer &&
12125
12/12
✓ Branch 0 taken 40621 times.
✓ Branch 1 taken 7905 times.
✓ Branch 2 taken 3586 times.
✓ Branch 3 taken 37035 times.
✓ Branch 4 taken 43407 times.
✓ Branch 5 taken 5119 times.
✓ Branch 6 taken 42638 times.
✓ Branch 7 taken 769 times.
✓ Branch 8 taken 3585 times.
✓ Branch 9 taken 2303 times.
✓ Branch 10 taken 2264 times.
✓ Branch 11 taken 1321 times.
48526 (((attack!=wSword || !current_item(itype_spinscroll) || inlikelike) && attack!=wWand && attack!=wFire && attack!=wCByrna) || !((attack==wSword && isWpnPressed(itype_sword) && spins==0) || charging>0)))
12126 {
12127 46239 tapping=false;
12128 46239 return false;
12129 }
12130
12131
2/2
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 839163 times.
839884 if(attackclk>29)
12132 {
12133 721 tapping=false;
12134 721 return false;
12135 }
12136
12137
4/4
✓ Branch 0 taken 29499 times.
✓ Branch 1 taken 809664 times.
✓ Branch 2 taken 27699 times.
✓ Branch 3 taken 1800 times.
839163 int32_t candleid = (directWpn>-1 && itemsbuf[directWpn].family==itype_candle) ? directWpn : current_item_id(itype_candle);
12138
3/4
✓ Branch 0 taken 29499 times.
✓ Branch 1 taken 809664 times.
✓ Branch 2 taken 29499 times.
✗ Branch 3 not taken.
839163 int32_t byrnaid = (directWpn>-1 && itemsbuf[directWpn].family==itype_cbyrna) ? directWpn : current_item_id(itype_cbyrna);
12139 // An attack can be "walked out-of" after 8 frames, unless it's:
12140 // * a sword stab
12141 // * a hammer pound
12142 // * a wand thrust
12143 // * a candle thrust
12144 // * a cane thrust
12145 // In which case it should continue.
12146
8/8
✓ Branch 0 taken 43731 times.
✓ Branch 1 taken 795432 times.
✓ Branch 2 taken 105688 times.
✓ Branch 3 taken 61957 times.
✓ Branch 4 taken 741442 times.
✓ Branch 5 taken 115947 times.
✓ Branch 6 taken 185575 times.
✓ Branch 7 taken 555867 times.
1002629 if((attack==wCatching && attackclk>4)||(attack!=wWand && attack!=wSword && attack!=wHammer
12147
5/6
✓ Branch 0 taken 163496 times.
✓ Branch 1 taken 22079 times.
✓ Branch 2 taken 13177 times.
✓ Branch 3 taken 150319 times.
✓ Branch 4 taken 13177 times.
✗ Branch 5 not taken.
185575 && (attack!=wFire || (candleid!=-1 && !(itemsbuf[candleid].wpn)))
12148
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 150289 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
163496 && (attack!=wCByrna || (byrnaid!=-1 && !(itemsbuf[byrnaid].wpn)))
12149
2/2
✓ Branch 0 taken 163466 times.
✓ Branch 1 taken 13177 times.
150319 && (attack != wBugNet) && attackclk>7))
12150 {
12151
8/8
✓ Branch 0 taken 54946 times.
✓ Branch 1 taken 2832 times.
✓ Branch 2 taken 52594 times.
✓ Branch 3 taken 2352 times.
✓ Branch 4 taken 49849 times.
✓ Branch 5 taken 2745 times.
✓ Branch 6 taken 2921 times.
✓ Branch 7 taken 46928 times.
269154 if(DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight())
12152 {
12153 10850 lstep = s;
12154 10850 return false;
12155 }
12156 46928 }
12157
12158
2/2
✓ Branch 0 taken 1916 times.
✓ Branch 1 taken 765289 times.
767205 if(charging==0)
12159 {
12160 765289 lstep=0;
12161 765289 }
12162
12163 // Work out the sword charge-up delay
12164 767205 int32_t magiccharge = 192, normalcharge = 64;
12165 767205 int32_t itemid = current_item_id(itype_chargering);
12166
12167
2/2
✓ Branch 0 taken 728138 times.
✓ Branch 1 taken 39067 times.
767205 if(itemid>=0)
12168 {
12169 39067 normalcharge = itemsbuf[itemid].misc1;
12170 39067 magiccharge = itemsbuf[itemid].misc2;
12171 39067 }
12172
12173 767205 int scrollid = current_item_id(attack==wHammer ? itype_quakescroll : itype_spinscroll);
12174 767205 int scroll2id = current_item_id(attack==wHammer ? itype_quakescroll2 : itype_spinscroll2);
12175
12176 767205 bool doCharge=true;
12177
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 767205 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
767205 if(z!=0 && fakez != 0)
12178 doCharge=false;
12179
2/2
✓ Branch 0 taken 555867 times.
✓ Branch 1 taken 211338 times.
767205 if(attack==wSword)
12180 {
12181
4/4
✓ Branch 0 taken 1661 times.
✓ Branch 1 taken 554206 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 1637 times.
555867 if(!(attackclk==SWORDCHARGEFRAME && isWpnPressed(itype_sword)))
12182 554230 doCharge=false;
12183
2/2
✓ Branch 0 taken 417 times.
✓ Branch 1 taken 1220 times.
1637 else if(charging<=normalcharge)
12184 {
12185
3/6
✓ Branch 0 taken 1220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1220 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1220 times.
✗ Branch 5 not taken.
1220 if(scrollid<0 || !(checkbunny(scrollid) && checkmagiccost(scrollid)))
12186 doCharge=false;
12187 1220 }
12188 555867 }
12189
2/2
✓ Branch 0 taken 22079 times.
✓ Branch 1 taken 189259 times.
211338 else if(attack==wHammer)
12190 {
12191
4/4
✓ Branch 0 taken 749 times.
✓ Branch 1 taken 21330 times.
✓ Branch 2 taken 740 times.
✓ Branch 3 taken 9 times.
22079 if(!(attackclk==HAMMERCHARGEFRAME && isWpnPressed(itype_hammer)))
12192 22070 doCharge=false;
12193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 else if(charging<=normalcharge)
12194 {
12195
4/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
9 if(scrollid<0 || !(checkbunny(scrollid) && checkmagiccost(scrollid)))
12196 1 doCharge=false;
12197 9 }
12198 22079 }
12199 else
12200 189259 doCharge=false;
12201
12202 // charging up weapon...
12203
2/2
✓ Branch 0 taken 1645 times.
✓ Branch 1 taken 765560 times.
767205 if(doCharge)
12204 {
12205 // Increase charging while holding down button.
12206
3/4
✓ Branch 0 taken 1645 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 1517 times.
1645 if(spins==0 && charging<magiccharge)
12207 1517 charging++;
12208
12209 // Once a charging threshold is reached, play the sound.
12210
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1636 times.
1645 if(charging==normalcharge)
12211 {
12212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!(itemsbuf[scrollid].flags&ITEM_FLAG1))
12213 9 paymagiccost(scrollid);
12214 9 sfx(itemsbuf[scrollid].usesound2,pan(x.getInt()));
12215 9 }
12216
2/2
✓ Branch 0 taken 1633 times.
✓ Branch 1 taken 3 times.
1636 else if(charging==magiccharge)
12217 {
12218
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if(scroll2id>-1 && checkbunny(scroll2id) && checkmagiccost(scroll2id))
12219 {
12220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!(itemsbuf[scroll2id].flags&ITEM_FLAG1))
12221 3 paymagiccost(scroll2id);
12222 3 charging++; // charging>magiccharge signifies a successful supercharge.
12223 3 sfx(itemsbuf[scroll2id].usesound2,pan(x.getInt()));
12224 3 }
12225 3 }
12226 1645 }
12227
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 765530 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
765560 else if(attack==wCByrna && byrnaid!=-1)
12228 {
12229
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!(itemsbuf[byrnaid].wpn))
12230 {
12231 attack = wNone;
12232 return startwpn(attackid); // Beam if the Byrna stab animation WASN'T used.
12233 }
12234
12235 30 bool beamcount = false;
12236
12237
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 55 times.
81 for(int32_t i=0; i<Lwpns.Count(); i++)
12238 {
12239 55 weapon *w = ((weapon*)Lwpns.spr(i));
12240
12241
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 4 times.
55 if(w->id==wCByrna)
12242 {
12243 4 beamcount = true;
12244 4 break;
12245 }
12246 51 }
12247
12248 // If beams already deployed, remove them
12249
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
30 if(!attackclk && beamcount)
12250 {
12251 2 return startwpn(attackid); // Remove beams instantly
12252 }
12253
12254 // Otherwise, continue
12255 28 ++attackclk;
12256 28 }
12257 else
12258 {
12259 765530 ++attackclk;
12260
12261
6/6
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 764732 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 773 times.
✓ Branch 4 taken 11 times.
✓ Branch 5 taken 14 times.
765530 if(attackclk==SWORDCHARGEFRAME && charging>0 && !tapping) //Signifies a tapped enemy
12262 {
12263 14 ++attackclk; // Won't continue charging
12264 14 charging=0;
12265 14 }
12266
12267 // Faster if spinning.
12268
2/2
✓ Branch 0 taken 764938 times.
✓ Branch 1 taken 592 times.
765530 if(spins>0)
12269 592 ++attackclk;
12270
12271 // Even faster if hurricane spinning.
12272
2/2
✓ Branch 0 taken 765098 times.
✓ Branch 1 taken 432 times.
765530 if(spins>5)
12273 432 attackclk+=2;
12274
12275 // If at a charging threshold, do a charged attack.
12276
5/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 765416 times.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 106 times.
✓ Branch 5 taken 8 times.
765530 if(charging>=normalcharge && (attack!=wSword || attackclk>=SWORDCHARGEFRAME) && !tapping)
12277 {
12278
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(attack==wSword)
12279 {
12280
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3 times.
8 bool super = charging>magiccharge && scroll2id > -1;
12281
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5 times.
8 int id = super ? scroll2id : scrollid;
12282 8 itemdata const& spinscroll = itemsbuf[id];
12283 8 bool paid = !(spinscroll.flags&ITEM_FLAG1);
12284
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8 if(!paid && checkbunny(id) && checkmagiccost(id))
12285 {
12286 paid = true;
12287 paymagiccost(id);
12288 }
12289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(paid)
12290 {
12291 8 currentscroll = id;
12292 8 spins=(spinscroll.misc1*4) + (super ? -3 : 1);
12293 8 attackclk=1;
12294 8 sfx(spinscroll.usesound,pan(x.getInt()));
12295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(spinscroll.flags&ITEM_FLAG1)
12296 paymagiccost(id);
12297 8 }
12298 8 }
12299 else if(attack==wHammer && sideviewhammerpound())
12300 {
12301 bool super = charging>magiccharge && scroll2id > -1;
12302 int id = super ? scroll2id : scrollid;
12303 itemdata const& quakescroll = itemsbuf[id];
12304 bool paid = !(quakescroll.flags&ITEM_FLAG1);
12305 if(!paid && checkbunny(id) && checkmagiccost(id))
12306 {
12307 paid = true;
12308 paymagiccost(id);
12309 }
12310 if(paid)
12311 {
12312 currentscroll = id;
12313 spins = super ? 2 : 1;
12314 sfx(quakescroll.usesound,pan(x.getInt()));
12315 quakeclk=quakescroll.misc1;
12316
12317 // general area stun
12318 for(int32_t i=0; i<GuyCount(); i++)
12319 {
12320 if(!isflier(GuyID(i)))
12321 {
12322 StunGuy(i,quakescroll.misc2-distance(x,y,GuyX(i),GuyY(i)));
12323 }
12324 }
12325
12326 int hmrid = (directWpn>-1 && itemsbuf[directWpn].family==itype_hammer) ? directWpn : current_item_id(itype_hammer);
12327 int hmrlvl = hmrid < 0 ? 1 : itemsbuf[hmrid].fam_type;
12328 if(hmrlvl < 1) hmrlvl = 1;
12329 int rad = quakescroll.misc2;
12330 for(int pos = 0; pos < 176; ++pos)
12331 {
12332 if(distance(x,y,COMBOX(pos),COMBOY(pos)) > rad) continue;
12333 for(int lyr = 0; lyr < 7; ++lyr)
12334 {
12335 int cid = FFCore.tempScreens[lyr]->data[pos];
12336 newcombo const& cmb = combobuf[cid];
12337 if(cmb.triggerflags[2] & ((super?combotriggerSQUAKESTUN:0)|combotriggerQUAKESTUN))
12338 {
12339 if((cmb.triggerflags[0]&combotriggerINVERTMINMAX)
12340 ? hmrlvl <= cmb.triggerlevel
12341 : hmrlvl >= cmb.triggerlevel)
12342 do_trigger_combo(lyr,pos);
12343 }
12344 }
12345 }
12346 word c = tmpscr->numFFC();
12347 for(int ff = 0; ff < c; ++ff)
12348 {
12349 ffcdata& ffc = tmpscr->ffcs[ff];
12350 newcombo const& cmb = combobuf[ffc.getData()];
12351 if(distance(x,y,ffc.x,ffc.y) > rad) continue;
12352 if(cmb.triggerflags[2] & ((super?combotriggerSQUAKESTUN:0)|combotriggerQUAKESTUN))
12353 {
12354 if((cmb.triggerflags[0]&combotriggerINVERTMINMAX)
12355 ? hmrlvl <= cmb.triggerlevel
12356 : hmrlvl >= cmb.triggerlevel)
12357 do_trigger_combo_ffc(ff);
12358 }
12359 }
12360 }
12361 }
12362 8 }
12363
6/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 765407 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 48 times.
765522 else if(tapping && attackclk<SWORDCHARGEFRAME && charging<magiccharge)
12364 48 charging++;
12365
12366
7/8
✓ Branch 0 taken 12950 times.
✓ Branch 1 taken 752580 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 752580 times.
✓ Branch 4 taken 21500 times.
✓ Branch 5 taken 731080 times.
✓ Branch 6 taken 450801 times.
✓ Branch 7 taken 314729 times.
765530 if(!isWpnPressed(attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword))
12367 314729 charging=0;
12368
12369
2/2
✓ Branch 0 taken 757431 times.
✓ Branch 1 taken 8099 times.
765530 if(attackclk>=SWORDCHARGEFRAME)
12370 8099 tapping = false;
12371 }
12372
12373
6/8
✓ Branch 0 taken 60482 times.
✓ Branch 1 taken 706721 times.
✓ Branch 2 taken 1087 times.
✓ Branch 3 taken 59395 times.
✓ Branch 4 taken 1087 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1087 times.
767203 if(attackclk==1 && attack==wFire && candleid!=-1 && !(itemsbuf[candleid].wpn))
12374 {
12375 1087 return startwpn(attackid); // Flame if the Candle stab animation WASN'T used.
12376 }
12377
12378 766116 int32_t crossid = current_item_id(itype_crossscroll); //has Cross Beams scroll
12379
12380
11/14
✓ Branch 0 taken 718702 times.
✓ Branch 1 taken 47414 times.
✓ Branch 2 taken 54820 times.
✓ Branch 3 taken 663882 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 54788 times.
✓ Branch 6 taken 32 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✓ Branch 9 taken 20 times.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
766116 if(attackclk==13 || (attackclk==7 && spins>1 && attack != wHammer && crossid >=0 && checkbunny(crossid) && checkmagiccost(crossid)))
12381 {
12382
12383
4/4
✓ Branch 0 taken 2003 times.
✓ Branch 1 taken 45423 times.
✓ Branch 2 taken 578 times.
✓ Branch 3 taken 1425 times.
47426 int32_t wpnid = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? directWpn : current_item_id(itype_sword);
12384
2/2
✓ Branch 0 taken 47408 times.
✓ Branch 1 taken 18 times.
47426 int64_t templife = wpnid>=0? itemsbuf[wpnid].misc1 : 0;
12385
12386
4/4
✓ Branch 0 taken 47408 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 3683 times.
✓ Branch 3 taken 43725 times.
47426 if(wpnid>=0 && itemsbuf[wpnid].flags & ITEM_FLAG1)
12387 {
12388 43725 templife=templife*game->get_maxlife();
12389 43725 templife=templife/100;
12390 43725 }
12391 else
12392 {
12393 3701 templife*=game->get_hp_per_heart();
12394 }
12395
12396
2/2
✓ Branch 0 taken 17178 times.
✓ Branch 1 taken 30248 times.
47426 bool normalbeam = (int64_t(game->get_life())+(get_bit(quest_rules,qr_QUARTERHEART)?((game->get_hp_per_heart()/4)-1):((game->get_hp_per_heart()/2)-1))>=templife);
12397 47426 int32_t perilid = current_item_id(itype_perilscroll);
12398
3/4
✓ Branch 0 taken 1637 times.
✓ Branch 1 taken 45789 times.
✓ Branch 2 taken 1637 times.
✗ Branch 3 not taken.
47429 bool perilbeam = (perilid>=0 && wpnid>=0 && game->get_life()<=itemsbuf[perilid].misc1*game->get_hp_per_heart()
12399
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1634 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
1637 && checkbunny(perilid) && checkmagiccost(perilid)
12400 // Must actually be able to shoot sword beams
12401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 && ((itemsbuf[wpnid].flags & ITEM_FLAG1)
12402
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 || itemsbuf[wpnid].misc1 <= game->get_maxlife()/game->get_hp_per_heart()));
12403
12404
4/4
✓ Branch 0 taken 38502 times.
✓ Branch 1 taken 8924 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 38483 times.
47426 if(attack==wSword && !tapping)
12405 {
12406
4/4
✓ Branch 0 taken 38480 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 13300 times.
✓ Branch 3 taken 25180 times.
38483 if(perilbeam || normalbeam)
12407 {
12408
1/2
✓ Branch 0 taken 13303 times.
✗ Branch 1 not taken.
13303 if(attackclk==7)
12409 paymagiccost(crossid); // Pay the Cross Beams magic cost.
12410
12411
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 13300 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
13303 if(perilbeam && !normalbeam)
12412 3 paymagiccost(perilid); // Pay the Peril Beam magic cost.
12413
12414 // TODO: Something that would be cheap but disgraceful to hack in at this point is
12415 // a way to make the peril/cross beam item's power stat influence the strength
12416 // of the peril/cross beam...
12417 13303 startwpn(attackid);
12418 13303 }
12419 25180 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
12420 38483 }
12421
12422
2/2
✓ Branch 0 taken 45891 times.
✓ Branch 1 taken 1535 times.
47426 if(attack==wWand)
12423 1535 startwpn(attackid); // Flame if the Wand stab animation WAS used (it always is).
12424
12425
4/6
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 46634 times.
✓ Branch 2 taken 792 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 792 times.
✗ Branch 5 not taken.
47426 if(attack==wFire && candleid!=-1 && itemsbuf[candleid].wpn) // Flame if the Candle stab animation WAS used.
12426 startwpn(attackid);
12427
12428
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 47424 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
47426 if(attack==wCByrna && byrnaid!=-1 && itemsbuf[byrnaid].wpn) // Beam if the Byrna stab animation WAS used.
12429 2 startwpn(attackid);
12430 47426 }
12431
12432
2/2
✓ Branch 0 taken 719189 times.
✓ Branch 1 taken 46927 times.
766116 if(attackclk==14)
12433 46927 lstep = s;
12434
12435 766116 return true;
12436 825015 }
12437
12438 12260356 bool HeroClass::can_attack()
12439 {
12440
4/4
✓ Branch 0 taken 12051026 times.
✓ Branch 1 taken 209330 times.
✓ Branch 2 taken 7191564 times.
✓ Branch 3 taken 4859462 times.
12260356 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
12441
4/6
✓ Branch 0 taken 12260356 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12131952 times.
✓ Branch 3 taken 128404 times.
✓ Branch 4 taken 12131952 times.
✗ Branch 5 not taken.
13110342 if(action==hopping || action==swimming || action==freeze || action==sideswimfreeze
12442
5/8
✓ Branch 0 taken 12131952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12131952 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12131952 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12130256 times.
✓ Branch 7 taken 1696 times.
12131952 || lstunclock > 0 || is_conveyor_stunned || spins>0 || usingActiveShield()
12443
3/4
✓ Branch 0 taken 12130256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10558864 times.
✓ Branch 3 taken 1571392 times.
12130256 || ((action==attacking||action==sideswimattacking)
12444
2/2
✓ Branch 0 taken 425000 times.
✓ Branch 1 taken 11705256 times.
12130256 && ((attack!=wSword && attack!=wWand) || !(itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5))
12445
2/2
✓ Branch 0 taken 12130242 times.
✓ Branch 1 taken 424986 times.
12130256 && charging!=0))
12446 {
12447 980086 return false;
12448 }
12449
12450 12130242 int32_t r = (isdungeon()) ? 16 : 0;
12451 12130242 int32_t r2 = get_bit(quest_rules, qr_NOBORDER) ? 0 : 8;
12452
12453
4/5
✓ Branch 0 taken 3401660 times.
✓ Branch 1 taken 8728582 times.
✓ Branch 2 taken 3847322 times.
✓ Branch 3 taken 4881260 times.
✗ Branch 4 not taken.
12130242 if(!get_bit(quest_rules, qr_ITEMSONEDGES)) switch(dir)
12454 {
12455 case up:
12456 case down:
12457
2/2
✓ Branch 0 taken 3696384 times.
✓ Branch 1 taken 150938 times.
3847322 return !(y<(r2+r) || y>(160-r-r2));
12458
12459 case left:
12460 case right:
12461
2/2
✓ Branch 0 taken 4727778 times.
✓ Branch 1 taken 153482 times.
4881260 return !(x<(r2+r) || x>(240-r-r2));
12462 }
12463
12464 3401660 return true;
12465 13110328 }
12466
12467 8884 bool isRaftFlag(int32_t flag)
12468 {
12469
4/4
✓ Branch 0 taken 4567 times.
✓ Branch 1 taken 4317 times.
✓ Branch 2 taken 222 times.
✓ Branch 3 taken 4345 times.
8884 return (flag==mfRAFT || flag==mfRAFT_BRANCH || flag==mfRAFT_BOUNCE);
12470 }
12471
12472 3713521 void handle_lens_triggers(int32_t l_id)
12473 {
12474
2/2
✓ Branch 0 taken 3707262 times.
✓ Branch 1 taken 6259 times.
3713521 bool enabled = l_id >= 0 && (itemsbuf[l_id].flags & ITEM_FLAG6);
12475
2/2
✓ Branch 0 taken 3713521 times.
✓ Branch 1 taken 25994647 times.
29708168 for(auto layer = 0; layer < 7; ++layer)
12476 {
12477 25994647 mapscr* tmp = FFCore.tempScreens[layer];
12478
2/2
✓ Branch 0 taken 4575057872 times.
✓ Branch 1 taken 25994647 times.
4601052519 for(auto pos = 0; pos < 176; ++pos)
12479 {
12480 4575057872 newcombo const& cmb = combobuf[tmp->data[pos]];
12481
4/4
✓ Branch 0 taken 280896 times.
✓ Branch 1 taken 4574776976 times.
✓ Branch 2 taken 4575057686 times.
✓ Branch 3 taken 186 times.
4575057872 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
12482 4574776976 : (cmb.triggerflags[1] & combotriggerLENSOFF))
12483 {
12484 186 do_trigger_combo(layer, pos);
12485 186 }
12486 4575057872 }
12487 25994647 }
12488
2/2
✓ Branch 0 taken 3557406 times.
✓ Branch 1 taken 156115 times.
3713521 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
12489 {
12490 156115 word c = tmpscr->numFFC();
12491
2/2
✓ Branch 0 taken 156115 times.
✓ Branch 1 taken 916150 times.
1072265 for(word i=0; i<c; i++)
12492 {
12493 916150 ffcdata& ffc = tmpscr->ffcs[i];
12494 916150 newcombo const& cmb = combobuf[ffc.getData()];
12495
3/4
✓ Branch 0 taken 1596 times.
✓ Branch 1 taken 914554 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 916150 times.
916150 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
12496 914554 : (cmb.triggerflags[1] & combotriggerLENSOFF))
12497 {
12498 do_trigger_combo_ffc(i);
12499 break;
12500 }
12501 916150 }
12502 156115 }
12503 3713521 }
12504
12505 6200490 void do_lens()
12506 {
12507
2/2
✓ Branch 0 taken 2486969 times.
✓ Branch 1 taken 3713521 times.
6200490 if ( FFCore.getQuestHeaderInfo(vZelda) < 0x250 ) //2.10 or earlier
12508 {
12509 2486969 do_210_lens();
12510 2486969 return;
12511 }
12512
12513 3713521 int32_t wpnPressed = getWpnPressed(itype_lens);
12514
6/6
✓ Branch 0 taken 6256 times.
✓ Branch 1 taken 3707265 times.
✓ Branch 2 taken 375 times.
✓ Branch 3 taken 3706890 times.
✓ Branch 4 taken 390142 times.
✓ Branch 5 taken 3316748 times.
3713521 int32_t itemid = lensid >= 0 ? lensid : wpnPressed>0 ? wpnPressed : Hero.getLastLensID()>0 ? Hero.getLastLensID() : current_item_id(itype_lens);
12515
2/2
✓ Branch 0 taken 2783207 times.
✓ Branch 1 taken 930314 times.
3713521 if(itemid >= 0)
12516 {
12517
8/10
✓ Branch 0 taken 5343 times.
✓ Branch 1 taken 924971 times.
✓ Branch 2 taken 5343 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 693 times.
✓ Branch 5 taken 4650 times.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 166 times.
✓ Branch 9 taken 527 times.
930314 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkbunny(itemid) && checkmagiccost(itemid))
12518 {
12519
2/2
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 209 times.
527 if(lensid<0)
12520 {
12521 209 lensid=itemid;
12522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 209 times.
209 if(itemsbuf[itemid].family == itype_lens)
12523 209 Hero.setLastLensID(itemid);
12524
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 12 times.
209 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
12525 209 }
12526
12527 527 paymagiccost(itemid, true); //Needs to ignore timer cause lensclk is our timer.
12528
12529
2/10
✓ Branch 0 taken 527 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 527 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
527 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
12530 {
12531 //clear the item script stack for a new script
12532 //itemScriptData[(itemid & 0xFFF)].Clear();
12533 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(itemid & 0xFFF)][q] = 0;
12534 ri = &(itemScriptData[itemid]);
12535 for ( int32_t q = 0; q < 1024; q++ ) item_stack[itemid][q] = 0xFFFF;
12536 ri->Clear();
12537 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid & 0xFFF);
12538 item_doscript[itemid] = 1;
12539 itemscriptInitialised[itemid] = 0;
12540 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid);
12541 did_scriptl=true;
12542 }
12543
12544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
527 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
12545 527 else lensclk = 12;
12546 527 }
12547 else
12548 {
12549 929787 did_scriptl=false;
12550
2/2
✓ Branch 0 taken 5732 times.
✓ Branch 1 taken 924055 times.
929787 if(!lensclk)
12551 {
12552
12553
2/2
✓ Branch 0 taken 923849 times.
✓ Branch 1 taken 206 times.
924055 if(lensid>-1)
12554 {
12555 206 lensid=-1;
12556 206 lensclk = 0;
12557
12558
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 11 times.
206 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
12559 206 }
12560 924055 }
12561 }
12562 930314 }
12563 3713521 handle_lens_triggers(lensid);
12564 6200490 }
12565 //Add 2.10 version check to call this
12566 2486969 void do_210_lens()
12567 {
12568
3/4
✓ Branch 0 taken 1680 times.
✓ Branch 1 taken 2485289 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2485289 times.
2486969 int32_t itemid = lensid >= 0 ? lensid : directWpn>-1 ? directWpn : current_item_id(itype_lens);
12569
12570
2/2
✓ Branch 0 taken 367843 times.
✓ Branch 1 taken 2119126 times.
2486969 if(itemid<0)
12571 2119126 return;
12572
12573
6/8
✓ Branch 0 taken 1680 times.
✓ Branch 1 taken 366163 times.
✓ Branch 2 taken 1680 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 248 times.
✓ Branch 5 taken 1432 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 248 times.
367843 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkmagiccost(itemid))
12574 {
12575
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 234 times.
248 if(lensid<0)
12576 {
12577 234 lensid=itemid;
12578
12579
1/2
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
234 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
12580 234 }
12581
12582 248 paymagiccost(itemid, true);
12583
12584
2/10
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
248 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
12585 {
12586 //clear the item script stack for a new script
12587 //itemScriptData[(itemid & 0xFFF)].Clear();
12588 ri = &(itemScriptData[itemid]);
12589 for ( int32_t q = 0; q < 1024; q++ ) item_stack[itemid][q] = 0xFFFF;
12590 ri->Clear();
12591 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(itemid & 0xFFF)][q] = 0;
12592 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid & 0xFFF);
12593 item_doscript[itemid] = 1;
12594 itemscriptInitialised[itemid] = 0;
12595 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid);
12596 did_scriptl=true;
12597 }
12598
12599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
248 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
12600 248 else lensclk = 12;
12601 248 }
12602 else
12603 {
12604 367595 did_scriptl=false;
12605
12606
6/8
✓ Branch 0 taken 1666 times.
✓ Branch 1 taken 365929 times.
✓ Branch 2 taken 1432 times.
✓ Branch 3 taken 234 times.
✓ Branch 4 taken 1432 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1432 times.
✗ Branch 7 not taken.
367595 if(lensid>-1 && !(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && checkmagiccost(itemid)))
12607 {
12608 234 lensid=-1;
12609 234 lensclk = 0;
12610
12611
1/2
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
234 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
12612 234 }
12613 }
12614 2486969 }
12615
12616 6123 void HeroClass::do_hopping()
12617 {
12618 6123 do_lens();
12619
12620
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 5951 times.
6123 if(hopclk==0xFF) //|| (diagonalMovement && hopclk >= 0xFF) )) // swimming
12621 //Possible fix for exiting water in diagonal movement. -Z
12622 {
12623 172 int32_t flippers_id = current_item_id(itype_flippers);
12624
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 169 times.
172 if(diveclk>0)
12625 {
12626 3 --diveclk;
12627
2/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && DrunkrAbtn()) //Cancellable Diving -V
12628 {
12629 diveclk = itemsbuf[flippers_id].misc2;
12630 }
12631 3 }
12632
1/2
✓ Branch 0 taken 169 times.
✗ Branch 1 not taken.
169 else if(DrunkrAbtn())
12633 {
12634 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
12635 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
12636
12637 if(global_diving==screen_diving)
12638 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
12639 }
12640
12641
3/8
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 172 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
172 if((!(x.getInt()&7) && !(y.getInt()&7)) || (diagonalMovement||NO_GRIDLOCK))
12642 {
12643 172 SetSwim();
12644 172 hopclk = 0;
12645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 172 times.
172 if (!IsSideSwim())
12646 {
12647 172 charging = attackclk = 0;
12648 172 tapping = false;
12649 172 }
12650 172 }
12651 else
12652 {
12653 herostep();
12654
12655 if(!isDiving() || (frame&1))
12656 {
12657 switch(dir)
12658 {
12659 case up:
12660 y -= 1;
12661 break;
12662
12663 case down:
12664 y += 1;
12665 break;
12666
12667 case left:
12668 x -= 1;
12669 break;
12670
12671 case right:
12672 x += 1;
12673 break;
12674 }
12675 }
12676 }
12677 172 }
12678 else // hopping in or out (need to separate the cases...)
12679 {
12680
4/6
✓ Branch 0 taken 5850 times.
✓ Branch 1 taken 101 times.
✓ Branch 2 taken 5850 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5850 times.
5951 if((diagonalMovement||NO_GRIDLOCK))
12681 {
12682
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 73 times.
101 if(hopclk==1) //hopping out
12683 //>= 1 possible fix for getting stuck on land edges.
12684 //No, this is not a clock. it's a type. 1 == out, 2 == in.
12685 {
12686
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(hopdir!=-1) dir=hopdir;
12687
12688 73 landswim=0;
12689
12690
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 43 times.
73 if(dir==up)
12691 {
12692 43 herostep();
12693 43 herostep();
12694 43 int32_t sidestep=0;
12695
12696
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 43 times.
43 if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12697 sidestep=1;
12698
3/6
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 43 times.
✗ Branch 5 not taken.
43 else if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12699 sidestep=2;
12700
12701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(sidestep==1) x++;
12702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 else if(sidestep==2) x--;
12703 43 else y--;
12704
12705
3/4
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 3 times.
43 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12706 {
12707 3 hopclk=0;
12708 3 diveclk=0;
12709 3 action=none; FFCore.setHeroAction(none);
12710 3 hopdir=-1;
12711 3 }
12712 43 }
12713
12714
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 30 times.
73 if(dir==down)
12715 {
12716 30 herostep();
12717 30 herostep();
12718 30 int32_t sidestep=0;
12719
12720
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
30 if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12721 sidestep=1;
12722
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 else if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12723 sidestep=2;
12724
12725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(sidestep==1) x++;
12726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 else if(sidestep==2) x--;
12727 30 else y++;
12728
12729
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
30 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12730 {
12731 2 hopclk=0;
12732 2 diveclk=0;
12733 2 action=none; FFCore.setHeroAction(none);
12734 2 hopdir=-1;
12735 2 }
12736 30 }
12737
12738
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(dir==left)
12739 {
12740 herostep();
12741 herostep();
12742 int32_t sidestep=0;
12743
12744 if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12745 sidestep=1;
12746 else if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12747 sidestep=2;
12748
12749 if(sidestep==1) y++;
12750 else if(sidestep==2) y--;
12751 else x--;
12752
12753 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12754 {
12755 hopclk=0;
12756 diveclk=0;
12757 action=none; FFCore.setHeroAction(none);
12758 hopdir=-1;
12759 }
12760 }
12761
12762
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(dir==right)
12763 {
12764 herostep();
12765 herostep();
12766 int32_t sidestep=0;
12767
12768 if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12769 sidestep=1;
12770 else if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12771 sidestep=2;
12772
12773 if(sidestep==1) y++;
12774 else if(sidestep==2) y--;
12775 else x++;
12776
12777 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12778 {
12779 hopclk=0;
12780 diveclk=0;
12781 action=none; FFCore.setHeroAction(none);
12782 hopdir=-1;
12783 }
12784 }
12785 73 }
12786
12787
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 28 times.
101 if(hopclk==2) //hopping in
12788 {
12789 28 landswim=0;
12790
12791
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(dir==up)
12792 {
12793 14 herostep();
12794 14 herostep();
12795 14 int32_t sidestep=0;
12796
12797
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
14 if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12798 sidestep=1;
12799
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
14 else if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12800 sidestep=2;
12801
12802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(sidestep==1) x++;
12803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 else if(sidestep==2) x--;
12804 14 else y--;
12805
12806
3/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 1 times.
14 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12807 {
12808 1 hopclk=0xFF;
12809 1 diveclk=0;
12810 1 SetSwim();
12811 1 }
12812 14 }
12813
12814
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(dir==down)
12815 {
12816 herostep();
12817 herostep();
12818 int32_t sidestep=0;
12819
12820 if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12821 sidestep=1;
12822 else if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12823 sidestep=2;
12824
12825 if(sidestep==1) x++;
12826 else if(sidestep==2) x--;
12827 else y++;
12828
12829 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12830 {
12831 hopclk=0xFF;
12832 diveclk=0;
12833 SetSwim();
12834 if (!IsSideSwim()) reset_swordcharge();
12835 }
12836 }
12837
12838
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(dir==left)
12839 {
12840 herostep();
12841 herostep();
12842 int32_t sidestep=0;
12843
12844 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12845 sidestep=1;
12846 else if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12847 sidestep=2;
12848
12849 if(sidestep==1) y++;
12850 else if(sidestep==2) y--;
12851 else x--;
12852
12853 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12854 {
12855 hopclk=0xFF;
12856 diveclk=0;
12857 SetSwim();
12858 }
12859 }
12860
12861
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(dir==right)
12862 {
12863 14 herostep();
12864 14 herostep();
12865
12866 14 int32_t sidestep=0;
12867
12868
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
14 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12869 sidestep=1;
12870
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
14 else if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12871 sidestep=2;
12872
12873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(sidestep==1) y++;
12874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 else if(sidestep==2) y--;
12875 14 else x++;
12876
12877
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
14 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12878 {
12879 1 hopclk=0xFF;
12880 1 diveclk=0;
12881 1 SetSwim();
12882 1 }
12883 14 }
12884 28 }
12885
12886 101 }
12887 else
12888 {
12889
7/8
✓ Branch 0 taken 2193 times.
✓ Branch 1 taken 3657 times.
✓ Branch 2 taken 2193 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1624 times.
✓ Branch 5 taken 569 times.
✓ Branch 6 taken 310 times.
✓ Branch 7 taken 3347 times.
5850 if((dir<left ? !(x.getInt()&7) && !(y.getInt()&15) : !(x.getInt()&15) && !(y.getInt()&7)))
12890 {
12891 569 action=none; FFCore.setHeroAction(none);
12892 569 hopclk = 0;
12893 569 diveclk = 0;
12894
12895
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 292 times.
569 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+8), currmap, currscr, -1, x.getInt(),y.getInt()+8, true, false))
12896 {
12897 // hopped in
12898 292 SetSwim();
12899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
292 if (!IsSideSwim()) attackclk = charging = spins = 0;
12900 292 }
12901 569 }
12902 else
12903 {
12904 5281 herostep();
12905 5281 herostep();
12906
12907
2/2
✓ Branch 0 taken 4972 times.
✓ Branch 1 taken 309 times.
5281 if(++hero_count>(16*hero_animation_speed))
12908 309 hero_count=0;
12909
12910 5281 int32_t xofs2 = x.getInt()&15;
12911 5281 int32_t yofs2 = y.getInt()&15;
12912 5281 int32_t s = 1 + (frame&1);
12913
12914
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 733 times.
✓ Branch 2 taken 1201 times.
✓ Branch 3 taken 1561 times.
✓ Branch 4 taken 1786 times.
5281 switch(dir)
12915 {
12916 case up:
12917
3/4
✓ Branch 0 taken 519 times.
✓ Branch 1 taken 214 times.
✓ Branch 2 taken 519 times.
✗ Branch 3 not taken.
733 if(yofs2<3 || yofs2>13) --y;
12918 519 else y-=s;
12919
12920 733 break;
12921
12922 case down:
12923
4/4
✓ Branch 0 taken 999 times.
✓ Branch 1 taken 202 times.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 840 times.
1201 if(yofs2<3 || yofs2>13) ++y;
12924 840 else y+=s;
12925
12926 1201 break;
12927
12928 case left:
12929
4/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 196 times.
✓ Branch 2 taken 260 times.
✓ Branch 3 taken 1105 times.
1561 if(xofs2<3 || xofs2>13) --x;
12930 1105 else x-=s;
12931
12932 1561 break;
12933
12934 case right:
12935
4/4
✓ Branch 0 taken 1485 times.
✓ Branch 1 taken 301 times.
✓ Branch 2 taken 237 times.
✓ Branch 3 taken 1248 times.
1786 if(xofs2<3 || xofs2>13) ++x;
12936 1248 else x+=s;
12937
12938 1786 break;
12939 }
12940 }
12941 }
12942 }
12943 6123 }
12944
12945 64189 void HeroClass::do_rafting()
12946 {
12947
12948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64189 times.
64189 if(toogam)
12949 {
12950 action=none; FFCore.setHeroAction(none);
12951 return;
12952 }
12953
12954 64189 FFCore.setHeroAction(rafting);
12955
12956 64189 do_lens();
12957
12958 64189 herostep();
12959
12960 //Calculate rafting speed
12961 64189 int32_t raft_item = current_item_id(itype_raft);
12962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64189 times.
64189 int32_t raft_step = (raft_item < 0 ? 1 : itemsbuf[raft_item].misc1);
12963 64189 raft_step = vbound(raft_step, -8, 5);
12964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64189 times.
64189 int32_t raft_time = raft_step < 0 ? 1<<(-raft_step) : 1;
12965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64189 times.
64189 if(raft_step < 0) raft_step = 1;
12966 64189 int32_t step_inc = 1 << (raft_step - 1);
12967 // Fix position
12968
1/2
✓ Branch 0 taken 64189 times.
✗ Branch 1 not taken.
64189 if(raft_step > 1)
12969 {
12970 if(x.getInt() & (step_inc-1))
12971 {
12972 x = x.getInt() & ~(step_inc-1);
12973 }
12974 if(y.getInt() & (step_inc-1))
12975 {
12976 y = y.getInt() & ~(step_inc-1);
12977 }
12978 }
12979 // Inc clock, check if we need to move this frame
12980 64189 ++raftclk;
12981
2/4
✓ Branch 0 taken 64189 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64189 times.
64189 if((raftclk % raft_time) || raft_step == 0) return; //No movement this frame
12982
12983
4/4
✓ Branch 0 taken 30394 times.
✓ Branch 1 taken 33795 times.
✓ Branch 2 taken 26029 times.
✓ Branch 3 taken 4365 times.
68441 if(!(x.getInt()&15) && !(y.getInt()&15))
12984 {
12985 // this sections handles switching to raft branches
12986
3/4
✓ Branch 0 taken 4144 times.
✓ Branch 1 taken 221 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4144 times.
4365 if((MAPFLAG(x,y)==mfRAFT_BRANCH||MAPCOMBOFLAG(x,y)==mfRAFT_BRANCH))
12987 {
12988
7/8
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 120 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 34 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
221 if(dir!=down && DrunkUp() && (isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
12989 {
12990 34 dir = up;
12991 34 goto skip;
12992 }
12993
12994
7/8
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 98 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 34 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 15 times.
187 if(dir!=up && DrunkDown() && (isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
12995 {
12996 34 dir = down;
12997 34 goto skip;
12998 }
12999
13000
7/8
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 94 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 19 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5 times.
153 if(dir!=right && DrunkLeft() && (isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
13001 {
13002 19 dir = left;
13003 19 goto skip;
13004 }
13005
13006
7/8
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 26 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
134 if(dir!=left && DrunkRight() && (isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
13007 {
13008 26 dir = right;
13009 26 goto skip;
13010 }
13011 108 }
13012
2/4
✓ Branch 0 taken 4144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4144 times.
4144 else if((MAPFLAG(x,y)==mfRAFT_BOUNCE||MAPCOMBOFLAG(x,y)==mfRAFT_BOUNCE))
13013 {
13014 if(dir == left) dir = right;
13015 else if(dir == right) dir = left;
13016 else if(dir == up) dir = down;
13017 else if(dir == down) dir = up;
13018 }
13019
13020
13021
3/4
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 3395 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 857 times.
4252 if(!isRaftFlag(nextflag(x,y,dir,false))&&!isRaftFlag(nextflag(x,y,dir,true)))
13022 {
13023
2/2
✓ Branch 0 taken 452 times.
✓ Branch 1 taken 405 times.
857 if(dir<left) //going up or down
13024 {
13025
3/4
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 276 times.
452 if((isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
13026 176 dir=right;
13027
3/4
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 160 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
276 else if((isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
13028 160 dir=left;
13029
4/4
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 102 times.
✓ Branch 3 taken 7 times.
116 else if(y>0 && y<160)
13030 {
13031 102 action=none; FFCore.setHeroAction(none);
13032 102 x = x.getInt();
13033 102 y = y.getInt();
13034 102 }
13035 452 }
13036 else //going left or right
13037 {
13038
3/4
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 166 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 239 times.
405 if((isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
13039 166 dir=down;
13040
3/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
239 else if((isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
13041 162 dir=up;
13042
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 else if(x>0 && x<240)
13043 {
13044 77 action=none; FFCore.setHeroAction(none);
13045 77 x = x.getInt();
13046 77 y = y.getInt();
13047 77 }
13048 }
13049 857 }
13050 4252 }
13051
13052 skip:
13053
13054
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14264 times.
✓ Branch 2 taken 13696 times.
✓ Branch 3 taken 16866 times.
✓ Branch 4 taken 19363 times.
64189 switch(dir)
13055 {
13056 case up:
13057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14264 times.
14264 if(x.getInt()&15)
13058 {
13059 if(x.getInt()&8)
13060 x++;
13061 else x--;
13062 }
13063 14264 else y -= step_inc;
13064
13065 14264 break;
13066
13067 case down:
13068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13696 times.
13696 if(x.getInt()&15)
13069 {
13070 if(x.getInt()&8)
13071 x++;
13072 else x--;
13073 }
13074 13696 else y += step_inc;
13075
13076 13696 break;
13077
13078 case left:
13079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16866 times.
16866 if(y.getInt()&15)
13080 {
13081 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
13082 {
13083 if ((y.getInt() % 16) < 4) y--;
13084 else y++;
13085 }
13086 else
13087 {
13088 if(y.getInt()&8)
13089 y++;
13090 else y--;
13091 }
13092 }
13093 16866 else x -= step_inc;
13094
13095 16866 break;
13096
13097 case right:
13098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19363 times.
19363 if(y.getInt()&15)
13099 {
13100 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
13101 {
13102 if ((y.getInt() % 16) <= 4) y--;
13103 else y++;
13104 }
13105 else
13106 {
13107 if(y.getInt()&8)
13108 y++;
13109 else y--;
13110 }
13111 }
13112 19363 else x += step_inc;
13113
13114 19363 break;
13115 }
13116 64189 }
13117
13118 9 bool HeroClass::try_hover()
13119 {
13120
6/10
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
9 if(hoverclk <= 0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
13121 {
13122 2 int32_t itemid = current_item_id(itype_hoverboots);
13123
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(hoverclk < 0)
13124 hoverclk = -hoverclk;
13125 else
13126 {
13127 2 fall = fakefall = jumping = 0;
13128
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemsbuf[itemid].misc1)
13129 2 hoverclk = itemsbuf[itemid].misc1;
13130 else
13131 {
13132 hoverclk = 1;
13133 hoverflags |= HOV_INF;
13134 }
13135
13136
13137 2 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
13138 }
13139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(itemsbuf[itemid].wpn)
13140
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 decorations.add(new dHover(x, y, dHOVER, 0));
13141 2 return true;
13142 }
13143 7 return false;
13144 9 }
13145
13146 //Returns bitwise; lower 8 are dir pulled in, next 16 are combo ID, 25th bit is bool for if can be resisted
13147 //Returns '-1' if not being pulled
13148 //Returns '-2' if should be falling in
13149 24006949 int32_t HeroClass::check_pitslide(bool ignore_hover)
13150 {
13151 //Pitfall todo -Emily
13152 //Iron boots; can't fight slipping, 2px/frame
13153 //Scripted variables to read pull dir/clk (clk only for non-hero)
13154 //Implement falling for all sprite types (npc AI)
13155 // Fall/slipping tiles for enemies
13156 // Fall/slipping SFX for enemies
13157 // Fall SFX for items/weapons
13158 // Weapons/Misc sprite shared for falling items/weapons
13159 //Maybe slip SFX for Hero?
13160 // Weapons/Misc sprite override for falling sprite?
13161 //Update std.zh with relevant new stuff
13162
2/2
✓ Branch 0 taken 1038540 times.
✓ Branch 1 taken 22968409 times.
24006949 if(can_pitfall(ignore_hover))
13163 {
13164
2/2
✓ Branch 0 taken 1794732 times.
✓ Branch 1 taken 21173677 times.
22968409 bool can_diag = (diagonalMovement || get_bit(quest_rules,qr_DISABLE_4WAY_GRIDLOCK));
13165 22968409 int32_t ispitul = getpitfall(x,y+(bigHitbox?0:8));
13166 22968409 int32_t ispitbl = getpitfall(x,y+15);
13167 22968409 int32_t ispitur = getpitfall(x+15,y+(bigHitbox?0:8));
13168 22968409 int32_t ispitbr = getpitfall(x+15,y+15);
13169 22968409 int32_t ispitul_50 = getpitfall(x+8,y+(bigHitbox?8:12));
13170 22968409 int32_t ispitbl_50 = getpitfall(x+8,y+(bigHitbox?7:11));
13171 22968409 int32_t ispitur_50 = getpitfall(x+7,y+(bigHitbox?8:12));
13172 22968409 int32_t ispitbr_50 = getpitfall(x+7,y+(bigHitbox?7:11));
13173 22968409 int32_t ispitul_75 = getpitfall(x+12,y+(bigHitbox?12:14));
13174 22968409 int32_t ispitbl_75 = getpitfall(x+12,y+(bigHitbox?3:9));
13175 22968409 int32_t ispitur_75 = getpitfall(x+3,y+(bigHitbox?12:14));
13176 22968409 int32_t ispitbr_75 = getpitfall(x+3,y+(bigHitbox?3:9));
13177 static const int32_t flag_pit_irresistable = (1<<24);
13178
5/5
✓ Branch 0 taken 22962153 times.
✓ Branch 1 taken 472 times.
✓ Branch 2 taken 109 times.
✓ Branch 3 taken 2969 times.
✓ Branch 4 taken 2706 times.
22968409 switch((ispitul?1:0) + (ispitur?1:0) + (ispitbl?1:0) + (ispitbr?1:0))
13179 {
13180 472 case 4: return -2; //Fully over pit; fall in
13181 case 3:
13182 {
13183
5/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 83 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
109 if(ispitul && ispitur && ispitbl) //UL_3
13184 {
13185
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(ispitul_50)
13186 {
13187
3/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
13188 6 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13189 }
13190 }
13191
3/6
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
87 else if(ispitul && ispitur && ispitbr) //UR_3
13192 {
13193 if(ispitur_50)
13194 {
13195 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
13196 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13197 }
13198 }
13199
4/6
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 83 times.
87 else if(ispitul && ispitbl && ispitbr) //BL_3
13200 {
13201
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 74 times.
83 if(ispitbl_50)
13202 {
13203
4/6
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7 times.
9 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
13204 9 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13205 }
13206 74 }
13207
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
4 else if(ispitbl && ispitur && ispitbr) //BR_3
13208 {
13209
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(ispitbr_50)
13210 {
13211
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
13212 4 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13213 }
13214 }
13215 74 break;
13216 }
13217 case 2:
13218 {
13219
4/4
✓ Branch 0 taken 1306 times.
✓ Branch 1 taken 1663 times.
✓ Branch 2 taken 1303 times.
✓ Branch 3 taken 3 times.
2969 if(ispitul && ispitur) //Up
13220 {
13221
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(DrunkDown())
13222 {
13223
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(ispitul_75 && ispitur_75) //Straight up
13224 {
13225 return up | flag_pit_irresistable | (ispitul << 8);
13226 }
13227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 else if(ispitul_75)
13228 {
13229 return (can_diag ? l_up : left) | flag_pit_irresistable | (ispitul << 8);
13230 }
13231
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 else if(ispitur_75)
13232 {
13233 return (can_diag ? r_up : right) | flag_pit_irresistable | (ispitur << 8);
13234 }
13235 3 else return -1;
13236 }
13237 else
13238 {
13239 if(ispitul_50 && ispitur_50) //Straight up
13240 {
13241 return up | ((ispitul_75 || ispitur_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
13242 }
13243 else if(ispitul_50)
13244 {
13245 if(DrunkRight() && !ispitul_75) return -1;
13246 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13247 }
13248 else if(ispitur_50)
13249 {
13250 if(DrunkLeft() && !ispitur_75) return -1;
13251 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13252 }
13253 }
13254 }
13255
4/4
✓ Branch 0 taken 1605 times.
✓ Branch 1 taken 1361 times.
✓ Branch 2 taken 1303 times.
✓ Branch 3 taken 302 times.
2966 else if(ispitbl && ispitbr) //Down
13256 {
13257
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 290 times.
302 if(DrunkUp())
13258 {
13259
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(ispitbl_75 && ispitbr_75) //Straight down
13260 {
13261 return down | flag_pit_irresistable | (ispitbl << 8);
13262 }
13263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 else if(ispitbl_75)
13264 {
13265 return (can_diag ? l_down : left) | flag_pit_irresistable | (ispitbl << 8);
13266 }
13267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 else if(ispitbr_75)
13268 {
13269 return (can_diag ? r_down : right) | flag_pit_irresistable | (ispitbr << 8);
13270 }
13271 12 else return -1;
13272 }
13273 else
13274 {
13275
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
290 if(ispitbl_50 && ispitbr_50) //Straight down
13276 {
13277 return down | ((ispitbl_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitbl << 8);
13278 }
13279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
290 else if(ispitbl_50)
13280 {
13281 if(DrunkRight() && !ispitbl_75) return -1;
13282 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13283 }
13284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
290 else if(ispitbr_50)
13285 {
13286 if(DrunkLeft() && !ispitbr_75) return -1;
13287 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13288 }
13289 }
13290 290 }
13291
3/4
✓ Branch 0 taken 1303 times.
✓ Branch 1 taken 1361 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1303 times.
2664 else if(ispitbl && ispitul) //Left
13292 {
13293
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 1161 times.
1303 if(DrunkRight())
13294 {
13295
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
142 if(ispitul_75 && ispitbl_75) //Straight left
13296 {
13297 return left | flag_pit_irresistable | (ispitul << 8);
13298 }
13299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 else if(ispitul_75)
13300 {
13301 return (can_diag ? l_up : up) | flag_pit_irresistable | (ispitul << 8);
13302 }
13303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 else if(ispitbl_75)
13304 {
13305 return (can_diag ? l_down : down) | flag_pit_irresistable | (ispitbl << 8);
13306 }
13307 142 else return -1;
13308 }
13309 else
13310 {
13311
3/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1140 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
1161 if(ispitul_50 && ispitbl_50) //Straight left
13312 {
13313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 return left | ((ispitul_75 || ispitbl_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
13314 }
13315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1140 times.
1140 else if(ispitul_50)
13316 {
13317 if(DrunkDown() && !ispitul_75) return -1;
13318 return (can_diag ? l_up : up) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13319 }
13320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1140 times.
1140 else if(ispitbl_50)
13321 {
13322 if(DrunkUp() && !ispitbl_75) return -1;
13323 return (can_diag ? l_down : down) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13324 }
13325 }
13326 1140 }
13327
2/4
✓ Branch 0 taken 1361 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1361 times.
1361 else if(ispitbr && ispitur) //Right
13328 {
13329
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 1232 times.
1361 if(DrunkLeft())
13330 {
13331
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
129 if(ispitur_75 && ispitbr_75) //Straight right
13332 {
13333 6 return right | flag_pit_irresistable | (ispitur << 8);
13334 }
13335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 else if(ispitur_75)
13336 {
13337 return (can_diag ? r_up : up) | flag_pit_irresistable | (ispitur << 8);
13338 }
13339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 else if(ispitbr_75)
13340 {
13341 return (can_diag ? r_down : down) | flag_pit_irresistable | (ispitbr << 8);
13342 }
13343 123 else return -1;
13344 }
13345 else
13346 {
13347
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1208 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
1232 if(ispitur_50 && ispitbr_50) //Straight right
13348 {
13349
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 16 times.
24 return right | ((ispitur_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitur << 8);
13350 }
13351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1208 times.
1208 else if(ispitur_50)
13352 {
13353 if(DrunkDown() && !ispitur_75) return -1;
13354 return (can_diag ? r_up : up) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13355 }
13356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1208 times.
1208 else if(ispitbr_50)
13357 {
13358 if(DrunkUp() && !ispitbr_75) return -1;
13359 return (can_diag ? r_down : down) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13360 }
13361 }
13362 1208 }
13363 2638 break;
13364 }
13365 case 1:
13366 {
13367
3/4
✓ Branch 0 taken 941 times.
✓ Branch 1 taken 1765 times.
✓ Branch 2 taken 941 times.
✗ Branch 3 not taken.
2706 if(ispitul && ispitul_50) //UL_1
13368 {
13369 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
13370 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13371 }
13372
4/4
✓ Branch 0 taken 460 times.
✓ Branch 1 taken 2246 times.
✓ Branch 2 taken 444 times.
✓ Branch 3 taken 16 times.
2706 if(ispitur && ispitur_50) //UR_1
13373 {
13374
2/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
13375 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13376 }
13377
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
2690 if(ispitbl && ispitbl_50) //BL_1
13378 {
13379 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
13380 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13381 }
13382
3/4
✓ Branch 0 taken 1129 times.
✓ Branch 1 taken 1561 times.
✓ Branch 2 taken 1129 times.
✗ Branch 3 not taken.
2690 if(ispitbr && ispitbr_50) //BR_1
13383 {
13384 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
13385 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13386 }
13387 2690 break;
13388 }
13389 }
13390 22967555 }
13391 24006095 return -1;
13392 24006949 }
13393
13394 5370624 bool HeroClass::pitslide() //Runs pitslide movement; returns true if pit is irresistable
13395 {
13396 5370624 pitfall();
13397
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5370622 times.
5370624 if(fallclk) return true;
13398 5370622 int32_t val = check_pitslide();
13399 //Val should not be -2 here; if -2 would have been returned, the 'return true' above should have triggered!
13400
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5370616 times.
5370622 if(val == -1)
13401 {
13402 5370616 pit_pulldir = -1;
13403 5370616 pit_pullclk = 0;
13404 5370616 return false;
13405 }
13406 6 int32_t dir = val&0xFF;
13407 6 int32_t cmbid = (val&0xFFFF00)>>8;
13408 6 int32_t sensitivity = combobuf[cmbid].attribytes[2];
13409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(combobuf[cmbid].usrflags&cflag5) //No pull at all
13410 {
13411 pit_pulldir = -1;
13412 pit_pullclk = 0;
13413 return false;
13414 }
13415
4/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 2 times.
6 if(dir > -1 && !(hoverflags & HOV_PITFALL_OUT) && try_hover()) //Engage hovers
13416 {
13417 2 pit_pulldir = -1;
13418 2 pit_pullclk = 0;
13419 2 return false;
13420 }
13421 4 pit_pulldir = dir;
13422 4 int32_t step = 1;
13423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(sensitivity == 0)
13424 {
13425 4 step = 2;
13426 4 sensitivity = 1;
13427 4 }
13428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(pit_pullclk++ % sensitivity) //No pull this frame
13429 return (val&0x100);
13430
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 4 times.
11 for(; step > 0 && !fallclk; --step)
13431 {
13432
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 switch(dir)
13433 {
13434 case l_up: case l_down: case left:
13435 --x; break;
13436 case r_up: case r_down: case right:
13437 7 ++x; break;
13438 }
13439
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
7 switch(dir)
13440 {
13441 case l_up: case r_up: case up:
13442 --y; break;
13443 case l_down: case r_down: case down:
13444 ++y; break;
13445 }
13446 7 pitfall();
13447 7 }
13448
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 return fallclk || (val&0x100);
13449 5370624 }
13450
13451 5370841 void HeroClass::pitfall()
13452 {
13453
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 5370631 times.
5370841 if(fallclk)
13454 {
13455 210 drop_liftwpn();
13456
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
210 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
13457 //Handle falling
13458
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 3 times.
210 if(!--fallclk)
13459 {
13460 3 int32_t dmg = game->get_hp_per_heart()/4;
13461 3 bool dmg_perc = false;
13462 3 bool warp = false;
13463
13464 3 action=none; FFCore.setHeroAction(none);
13465
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 newcombo* cmb = fallCombo ? &combobuf[fallCombo] : NULL;
13466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(cmb)
13467 {
13468 3 dmg = cmb->attributes[0]/10000L;
13469 3 dmg_perc = cmb->usrflags&cflag3;
13470 3 warp = cmb->usrflags&cflag1;
13471 3 }
13472
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(cheat_superman && dmg > 0)
13473 dmg = 0;
13474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(dmg) //Damage
13475 {
13476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(dmg > 0) hclk=48; //IFrames only if damaged, not if healed
13477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 game->set_life(vbound(int32_t(dmg_perc ? game->get_life() - ((vbound(dmg,-100,100)/100.0)*game->get_maxlife()) : (game->get_life()-int64_t(dmg))),0,game->get_maxlife()));
13478 3 }
13479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(warp) //Warp
13480 {
13481 sdir = dir;
13482 if(cmb->usrflags&cflag2) //Direct Warp
13483 {
13484 didpit=true;
13485 pitx=x;
13486 pity=y;
13487 }
13488 dowarp(0,vbound(cmb->attribytes[1],0,3),0);
13489 }
13490 else //Reset to screen entry
13491 {
13492 3 go_respawn_point();
13493 }
13494 3 }
13495 210 }
13496
2/2
✓ Branch 0 taken 329280 times.
✓ Branch 1 taken 5041351 times.
5370631 else if(can_pitfall())
13497 {
13498 5041351 bool ispitul = ispitfall(x,y+(bigHitbox?0:8));
13499 5041351 bool ispitbl = ispitfall(x,y+15);
13500 5041351 bool ispitur = ispitfall(x+15,y+(bigHitbox?0:8));
13501 5041351 bool ispitbr = ispitfall(x+15,y+15);
13502 5041351 int32_t pitctr = getpitfall(x+8,y+(bigHitbox?8:12));
13503
9/10
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 5040870 times.
✓ Branch 2 taken 264 times.
✓ Branch 3 taken 217 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 258 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
5041351 if(ispitul && ispitbl && ispitur && ispitbr && pitctr)
13504 {
13505
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!(hoverflags & HOV_PITFALL_OUT) && try_hover()) return;
13506
3/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
3 if(!bigHitbox && !ispitfall(x,y)) y = (y.getInt() + 8 - (y.getInt() % 8)); //Make the falling sprite fully over the pit
13507 3 fallclk = PITFALL_FALL_FRAMES;
13508 3 fallCombo = pitctr;
13509 3 action=falling; FFCore.setHeroAction(falling);
13510 3 spins = 0;
13511 3 charging = 0;
13512 3 drop_liftwpn();
13513 3 }
13514 5041351 }
13515 5370841 }
13516
13517 11473 void HeroClass::mod_steps(std::vector<zfix*>& v)
13518 {
13519
3/4
✓ Branch 0 taken 11109 times.
✓ Branch 1 taken 364 times.
✓ Branch 2 taken 11109 times.
✗ Branch 3 not taken.
11473 bool can_combo = ((z==0 && fakez==0) || tmpscr->flags2&fAIRCOMBOS);
13520
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11473 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22946 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1,-1) && can_combo) ||
13521
5/6
✓ Branch 0 taken 7802 times.
✓ Branch 1 taken 3671 times.
✓ Branch 2 taken 2164 times.
✓ Branch 3 taken 5638 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7802 times.
11473 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1,-1));
13522 //!DIMITODO: add QR for slow combos under hero
13523
1/4
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11473 if(slowcombo) for (int32_t i = 0; i <= 1; ++i)
13524 {
13525 if(tmpscr2[i].valid!=0)
13526 {
13527 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
13528 {
13529 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && !_walkflag_layer(x+7,y+8,1, &(tmpscr2[i])))
13530 {
13531 slowcombo = false;
13532 break;
13533 }
13534 }
13535 else
13536 {
13537 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && _effectflag_layer(x+7,y+8,1, &(tmpscr2[i])))
13538 {
13539 slowcombo = false;
13540 break;
13541 }
13542 }
13543 }
13544 }
13545
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
13546 11473 bool is_swimming = (action == swimming);
13547 11473 int32_t shieldid = getCurrentActiveShield();
13548
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 if(shieldid > -1)
13549 {
13550 itemdata const& shield = itemsbuf[shieldid];
13551 if(shield.flags & ITEM_FLAG10) //Change Speed flag
13552 {
13553 zfix perc = shield.misc7;
13554 perc /= 100;
13555 if(perc < 0)
13556 perc = (perc*-1)+1;
13557 zfix add(shield.misc8);
13558 add /= 100;
13559 for(zfix* stp : v)
13560 {
13561 zfix& pix = *stp;
13562 pix = (pix * perc) + add;
13563 }
13564 }
13565 }
13566
13567 11473 auto slow_cpos = COMBOPOS(x+7,y+8);
13568
4/4
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 11109 times.
✓ Branch 2 taken 11109 times.
✓ Branch 3 taken 77763 times.
89236 if(can_combo) for(int q = 6; q >= 0; --q)
13569 {
13570 77763 mapscr* m = FFCore.tempScreens[q];
13571
2/2
✓ Branch 0 taken 13780 times.
✓ Branch 1 taken 63983 times.
77763 if(!m->valid) continue;
13572 13780 newcombo const& cmb = combobuf[m->data[slow_cpos]];
13573
13574
2/2
✓ Branch 0 taken 68900 times.
✓ Branch 1 taken 13780 times.
82680 for(zfix* stp : v)
13575 {
13576 68900 zfix& pix = *stp;
13577 68900 pix *= cmb.speed_mult;
13578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68900 times.
68900 if(cmb.speed_div)
13579 68900 pix /= cmb.speed_div;
13580 68900 pix += cmb.speed_add;
13581 }
13582
3/4
✓ Branch 0 taken 2671 times.
✓ Branch 1 taken 11109 times.
✓ Branch 2 taken 2671 times.
✗ Branch 3 not taken.
13780 if(q > 0 && cmb.type == cBRIDGE)
13583 {
13584 if(get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS)
13585 ? !_walkflag_layer(x+7,y+8,1,&(tmpscr2[q-1]))
13586 : _effectflag_layer(x+7,y+8,1,&(tmpscr2[q-1])))
13587 {
13588 break; //Bridge blocks speed change from below it
13589 }
13590 }
13591 24889 }
13592 11473 zfix mult = 1, div = 1;
13593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11473 times.
11473 if(is_swimming)
13594 {
13595 mult = game->swim_mult;
13596 div = game->swim_div;
13597 }
13598
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11473 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11473 else if(slowcharging && slowcombo) //1/2 speed
13599 {
13600 div = 2;
13601 }
13602
2/4
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11473 times.
11473 else if(slowcharging || slowcombo) //2/3 speed
13603 {
13604 mult = 2;
13605 div = 3;
13606 }
13607
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 if(!div) div = 1;
13608
2/4
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11473 times.
11473 if(mult != 1 || div != 1)
13609 {
13610 for(zfix* stp : v)
13611 {
13612 zfix& pix = *stp;
13613 pix = ((pix / div) * mult);
13614 }
13615 }
13616 11473 }
13617
13618 6178792 void HeroClass::moveheroOld()
13619 {
13620
2/4
✓ Branch 0 taken 6178792 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6178792 times.
6178792 if(lstunclock || is_conveyor_stunned) return;
13621 6178792 int32_t xoff=x.getInt()&7;
13622 6178792 int32_t yoff=y.getInt()&7;
13623
3/4
✓ Branch 0 taken 6166537 times.
✓ Branch 1 taken 12255 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6166537 times.
6178792 if(NO_GRIDLOCK)
13624 {
13625 12255 xoff = 0;
13626 12255 yoff = 0;
13627 12255 }
13628 6178792 int32_t push=pushing;
13629 6178792 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
13630 6178792 pushing=0;
13631 6178792 zfix temp_step(hero_newstep);
13632 6178792 zfix temp_x(x);
13633 6178792 zfix temp_y(y);
13634
13635 6178792 int32_t flippers_id = current_item_id(itype_flippers);
13636 6178792 itemdata const& itm = itemsbuf[flippers_id];
13637 6178792 byte intbtn = byte(itm.misc3&0xFF);
13638 6178792 bool dive_pressed = getIntBtnInput(intbtn, true, true, false, false, true);
13639 6178792 bool eatdive = false;
13640
2/2
✓ Branch 0 taken 5519 times.
✓ Branch 1 taken 6173273 times.
6178792 if(diveclk>0)
13641 {
13642
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5519 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5519 if (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM)) diveclk = 0;
13643 5519 --diveclk;
13644
4/8
✓ Branch 0 taken 3688 times.
✓ Branch 1 taken 1831 times.
✓ Branch 2 taken 3688 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3688 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
5519 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && dive_pressed) //Cancellable Diving -V
13645 {
13646 diveclk = itemsbuf[flippers_id].misc2;
13647 eatdive = true;
13648 }
13649 5519 }
13650
4/4
✓ Branch 0 taken 59148 times.
✓ Branch 1 taken 6114125 times.
✓ Branch 2 taken 59060 times.
✓ Branch 3 taken 88 times.
6173273 else if(action == swimming && dive_pressed)
13651 {
13652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
13653 88 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
13654
13655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(global_diving==screen_diving)
13656 {
13657
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
13658 88 eatdive = true;
13659 88 }
13660 88 }
13661
2/2
✓ Branch 0 taken 6178704 times.
✓ Branch 1 taken 88 times.
6178792 if(eatdive)
13662 88 getIntBtnInput(intbtn, true, true, false, false, false);
13663
13664
2/2
✓ Branch 0 taken 6114603 times.
✓ Branch 1 taken 64189 times.
6178792 if(action==rafting)
13665 {
13666 64189 do_rafting();
13667
13668
2/2
✓ Branch 0 taken 64010 times.
✓ Branch 1 taken 179 times.
64189 if(action==rafting)
13669 {
13670 64010 return;
13671 }
13672
13673
13674 179 set_respawn_point();
13675 179 trySideviewLadder();
13676 179 }
13677
13678 6114782 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
13679 6114782 int32_t btnwpn = -1;
13680
13681 //&0xFFF removes the "bow & arrows" bitmask
13682 //The Quick Sword is allowed to interrupt attacks.
13683
4/4
✓ Branch 0 taken 6010117 times.
✓ Branch 1 taken 104665 times.
✓ Branch 2 taken 3593845 times.
✓ Branch 3 taken 2416272 times.
6114782 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
13684
8/8
✓ Branch 0 taken 5351154 times.
✓ Branch 1 taken 763628 times.
✓ Branch 2 taken 5345384 times.
✓ Branch 3 taken 5770 times.
✓ Branch 4 taken 215492 times.
✓ Branch 5 taken 553906 times.
✓ Branch 6 taken 33262 times.
✓ Branch 7 taken 736136 times.
6114782 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5)))
13685 {
13686
2/2
✓ Branch 0 taken 15747 times.
✓ Branch 1 taken 5362899 times.
5378646 if(DrunkrBbtn())
13687 {
13688 15747 btnwpn=getItemFamily(itemsbuf,Bwpn&0xFFF);
13689 15747 dowpn = Bwpn&0xFFF;
13690 15747 directWpn = directItemB;
13691 15747 }
13692
2/2
✓ Branch 0 taken 42595 times.
✓ Branch 1 taken 5320304 times.
5362899 else if(DrunkrAbtn())
13693 {
13694 42595 btnwpn=getItemFamily(itemsbuf,Awpn&0xFFF);
13695 42595 dowpn = Awpn&0xFFF;
13696 42595 directWpn = directItemA;
13697 42595 }
13698
4/4
✓ Branch 0 taken 71669 times.
✓ Branch 1 taken 5248635 times.
✓ Branch 2 taken 71662 times.
✓ Branch 3 taken 7 times.
5320304 else if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
13699 {
13700 7 btnwpn=getItemFamily(itemsbuf,Xwpn&0xFFF);
13701 7 dowpn = Xwpn&0xFFF;
13702 7 directWpn = directItemX;
13703 7 }
13704
4/4
✓ Branch 0 taken 71662 times.
✓ Branch 1 taken 5248635 times.
✓ Branch 2 taken 71557 times.
✓ Branch 3 taken 105 times.
5320297 else if(get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
13705 {
13706 105 btnwpn=getItemFamily(itemsbuf,Ywpn&0xFFF);
13707 105 dowpn = Ywpn&0xFFF;
13708 105 directWpn = directItemY;
13709 105 }
13710
13711
1/2
✓ Branch 0 taken 5378646 times.
✗ Branch 1 not taken.
5378646 if(directWpn > 255) directWpn = 0;
13712
13713 // The Quick Sword only allows repeated sword or wand swings.
13714
7/8
✓ Branch 0 taken 5345384 times.
✓ Branch 1 taken 33262 times.
✓ Branch 2 taken 33262 times.
✓ Branch 3 taken 5345384 times.
✓ Branch 4 taken 32749 times.
✓ Branch 5 taken 513 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5345897 times.
5378646 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
13715 32749 btnwpn=-1;
13716 5378646 }
13717
13718
2/2
✓ Branch 0 taken 317704 times.
✓ Branch 1 taken 5797078 times.
6114782 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
13719
11/12
✓ Branch 0 taken 5726575 times.
✓ Branch 1 taken 388207 times.
✓ Branch 2 taken 5482169 times.
✓ Branch 3 taken 244406 times.
✓ Branch 4 taken 5407553 times.
✓ Branch 5 taken 74616 times.
✓ Branch 6 taken 5364621 times.
✓ Branch 7 taken 42932 times.
✓ Branch 8 taken 40833 times.
✓ Branch 9 taken 5323788 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 40833 times.
6114782 if(can_attack() && (swordid > -1 && itemsbuf[swordid].family==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
13720 {
13721
2/2
✓ Branch 0 taken 1566 times.
✓ Branch 1 taken 39267 times.
40833 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
13722
5/6
✓ Branch 0 taken 40831 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 40816 times.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
40833 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & ITEM_FLAG6)))
13723 {
13724
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 40816 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
40816 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
13725 {
13726 paymagiccost(attackid,true);
13727 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
13728 }
13729 40816 SetAttack();
13730 40816 attack=wSword;
13731
13732 40816 attackclk=0;
13733
2/2
✓ Branch 0 taken 1551 times.
✓ Branch 1 taken 39265 times.
40816 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x.getInt()));
13734
13735
2/10
✓ Branch 0 taken 40816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 40816 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
40816 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(item_doscript[dowpn] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
13736 {
13737 if(!checkmagiccost(dowpn))
13738 {
13739 item_error();
13740 }
13741 else
13742 {
13743 //clear the item script stack for a new script
13744
13745 ri = &(itemScriptData[dowpn]);
13746 for ( int32_t q = 0; q < 1024; q++ ) item_stack[dowpn][q] = 0xFFFF;
13747 ri->Clear();
13748 //itemScriptData[(dowpn & 0xFFF)].Clear();
13749 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(dowpn & 0xFFF)][q] = 0;
13750 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn & 0xFFF);
13751 item_doscript[dowpn] = 1;
13752 itemscriptInitialised[dowpn] = 0;
13753 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn);
13754 did_scripta=true;
13755 }
13756 }
13757 40816 }
13758 else
13759 {
13760 17 item_error();
13761 }
13762 40833 }
13763 else
13764 {
13765 6073949 did_scripta=false;
13766 }
13767
13768
6/10
✓ Branch 0 taken 6050580 times.
✓ Branch 1 taken 64202 times.
✓ Branch 2 taken 6050580 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6050580 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6050580 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6050580 times.
6114782 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
13769 {
13770
3/4
✓ Branch 0 taken 975814 times.
✓ Branch 1 taken 5074766 times.
✓ Branch 2 taken 975814 times.
✗ Branch 3 not taken.
6050580 if(DrunkUp() && canSideviewLadder())
13771 {
13772 setOnSideviewLadder(true);
13773 }
13774
3/4
✓ Branch 0 taken 816490 times.
✓ Branch 1 taken 5234090 times.
✓ Branch 2 taken 816490 times.
✗ Branch 3 not taken.
6050580 else if(DrunkDown() && canSideviewLadder(true))
13775 {
13776 y+=1;
13777 setOnSideviewLadder(true);
13778 }
13779 6050580 }
13780
13781 6114782 int32_t wx=x;
13782 6114782 int32_t wy=y;
13783
3/6
✓ Branch 0 taken 4031137 times.
✓ Branch 1 taken 2083645 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6114782 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6114782 if((action==none || action==walking) && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
13784 {
13785 if((xoff==0)||diagonalMovement)
13786 {
13787 if(DrunkUp()) dir=up;
13788 if(DrunkDown()) dir=down;
13789 }
13790
13791 if((yoff==0)||diagonalMovement)
13792 {
13793 if(DrunkLeft()) dir=left;
13794 if(DrunkRight()) dir=right;
13795 }
13796 }
13797
13798
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1411840 times.
✓ Branch 2 taken 1195963 times.
✓ Branch 3 taken 1673088 times.
✓ Branch 4 taken 1833891 times.
6114782 switch(dir)
13799 {
13800 case up:
13801 1411840 wy-=16;
13802 1411840 break;
13803
13804 case down:
13805 1195963 wy+=16;
13806 1195963 break;
13807
13808 case left:
13809 1673088 wx-=16;
13810 1673088 break;
13811
13812 case right:
13813 1833891 wx+=16;
13814 1833891 break;
13815 }
13816
13817 6114782 do_lens();
13818
13819 6114782 WalkflagInfo info;
13820
13821 6114782 bool no_jinx = true;
13822
7/8
✓ Branch 0 taken 5726575 times.
✓ Branch 1 taken 388207 times.
✓ Branch 2 taken 16983 times.
✓ Branch 3 taken 5709592 times.
✓ Branch 4 taken 16983 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1084 times.
✓ Branch 7 taken 15899 times.
6114782 if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
13823 {
13824 15899 bool paidmagic = false;
13825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15899 times.
15899 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
13826
7/10
✓ Branch 0 taken 15899 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14363 times.
✓ Branch 3 taken 1536 times.
✓ Branch 4 taken 489 times.
✓ Branch 5 taken 1047 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 489 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1536 times.
15899 if(!liftonly && btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_wand : false) : current_item(itype_wand)))
13827 {
13828
2/2
✓ Branch 0 taken 489 times.
✓ Branch 1 taken 1047 times.
1536 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
13829 1536 no_jinx = checkitem_jinx(attackid);
13830
3/8
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1536 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1536 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
13831 {
13832
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1536 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
13833 paymagiccost(attackid,true);
13834 misc_internal_hero_flags |= LF_PAID_WAND_COST;
13835 }
13836 1536 SetAttack();
13837 1536 attack=wWand;
13838 1536 attackclk=0;
13839 1536 }
13840 else
13841 {
13842 item_error();
13843 }
13844 1536 }
13845
5/8
✓ Branch 0 taken 14363 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 765 times.
✓ Branch 3 taken 13598 times.
✓ Branch 4 taken 765 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 765 times.
15128 else if(!liftonly && (btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
13846
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 765 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 763 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
765 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_hammer : false) : current_item(itype_hammer)))
13847 {
13848 765 no_jinx = checkitem_jinx(dowpn);
13849
3/6
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 765 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 765 times.
765 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
13850 {
13851 item_error();
13852 }
13853 else
13854 {
13855 765 paymagiccost(dowpn);
13856 765 paidmagic = true;
13857 765 SetAttack();
13858 765 attack=wHammer;
13859
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 763 times.
765 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
13860 765 attackclk=0;
13861 }
13862 765 }
13863
5/8
✓ Branch 0 taken 13598 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1165 times.
✓ Branch 3 taken 12433 times.
✓ Branch 4 taken 1165 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1165 times.
14763 else if(!liftonly && (btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
13864
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1165 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 997 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
1165 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_candle : false) : current_item(itype_candle)))
13865 {
13866 //checkbunny handled where magic cost is paid
13867
2/2
✓ Branch 0 taken 997 times.
✓ Branch 1 taken 168 times.
1165 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
13868 1165 no_jinx = checkitem_jinx(attackid);
13869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1165 times.
1165 if(no_jinx)
13870 {
13871 1165 SetAttack();
13872 1165 attack=wFire;
13873 1165 attackclk=0;
13874 1165 }
13875 1165 }
13876
5/8
✓ Branch 0 taken 12433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 12429 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
12437 else if(!liftonly && (btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
13877
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_cbyrna : false) : current_item(itype_cbyrna)))
13878 {
13879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
13880 4 no_jinx = checkitem_jinx(attackid);
13881
3/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
13882 {
13883
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
13884 paymagiccost(attackid,true);
13885 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
13886 }
13887 4 SetAttack();
13888 4 attack=wCByrna;
13889 4 attackclk=0;
13890 4 }
13891 else
13892 {
13893 item_error();
13894 }
13895 4 }
13896
2/8
✓ Branch 0 taken 12429 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12429 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
12429 else if(!liftonly && (btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
13897 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].family==itype_bugnet) : current_item(itype_bugnet)))
13898 {
13899 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
13900 no_jinx = checkitem_jinx(attackid);
13901 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
13902 {
13903 paymagiccost(attackid);
13904 SetAttack();
13905 attack = wBugNet;
13906 attackclk = 0;
13907 sfx(itemsbuf[attackid].usesound);
13908 }
13909 else
13910 {
13911 item_error();
13912 }
13913 }
13914 else
13915 {
13916
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 12352 times.
12429 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
13917 12429 no_jinx = checkitem_jinx(itmid);
13918
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 12415 times.
12429 if(no_jinx)
13919 {
13920 12415 paidmagic = startwpn(itmid);
13921
13922
2/2
✓ Branch 0 taken 10419 times.
✓ Branch 1 taken 1996 times.
12415 if(paidmagic)
13923 {
13924
5/10
✓ Branch 0 taken 10419 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10419 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10419 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10419 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 10419 times.
10419 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
13925 {
13926 ;
13927 }
13928 else
13929 {
13930 10419 SetAttack();
13931 10419 attackclk=0;
13932 10419 attack=none;
13933
13934
2/2
✓ Branch 0 taken 1746 times.
✓ Branch 1 taken 8673 times.
10419 if(btnwpn==itype_brang)
13935 {
13936 8673 attack=wBrang;
13937 8673 }
13938 }
13939 10419 }
13940 else
13941 {
13942 // Weapon not started: directWpn should be reset to prev. value.
13943 1996 directWpn = olddirectwpn;
13944 }
13945 12415 }
13946 }
13947
13948
8/12
✓ Branch 0 taken 15899 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15885 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 866 times.
✓ Branch 5 taken 15019 times.
✓ Branch 6 taken 800 times.
✓ Branch 7 taken 66 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
15899 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(item_doscript[dowpn] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
13949 {
13950
3/4
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 800 times.
800 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
13951 {
13952 item_error();
13953 }
13954 else
13955 {
13956 // Only charge for magic if item's magic cost wasn't already charged
13957 // for the item's main use.
13958
4/4
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 795 times.
800 if(!paidmagic && attack!=wWand)
13959 795 paymagiccost(dowpn);
13960 //clear the item script stack for a new script
13961 //itemScriptData[(dowpn & 0xFFF)].Clear();
13962 800 ri = &(itemScriptData[dowpn]);
13963
2/2
✓ Branch 0 taken 819200 times.
✓ Branch 1 taken 800 times.
820000 for ( int32_t q = 0; q < 1024; q++ ) item_stack[dowpn][q] = 0xFFFF;
13964 800 ri->Clear();
13965 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(dowpn & 0xFFF)][q] = 0;
13966 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn & 0xFFF);
13967 800 item_doscript[dowpn] = 1;
13968 800 itemscriptInitialised[dowpn] = 0;
13969 800 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn);
13970 800 did_scriptb=true;
13971 }
13972 800 }
13973
13974
7/12
✓ Branch 0 taken 15885 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 15885 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15885 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15885 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15885 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 15885 times.
15899 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
13975 {
13976 return;
13977 }
13978
2/2
✓ Branch 0 taken 15885 times.
✓ Branch 1 taken 14 times.
15899 if(!no_jinx)
13979 14 did_scriptb = false;
13980 15899 }
13981 else
13982 {
13983 6098883 did_scriptb=false;
13984 }
13985
13986
5/6
✓ Branch 0 taken 5351666 times.
✓ Branch 1 taken 763116 times.
✓ Branch 2 taken 5291190 times.
✓ Branch 3 taken 60476 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5291190 times.
6114782 if(attackclk || action==attacking || action==sideswimattacking)
13987 {
13988
13989
4/8
✓ Branch 0 taken 60476 times.
✓ Branch 1 taken 763116 times.
✓ Branch 2 taken 60476 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 60476 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
823592 if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
13990 {
13991 if((xoff==0)||diagonalMovement)
13992 {
13993 if(DrunkUp()) dir=up;
13994 if(DrunkDown()) dir=down;
13995 }
13996
13997 if((yoff==0)||diagonalMovement)
13998 {
13999 if(DrunkLeft()) dir=left;
14000 if(DrunkRight()) dir=right;
14001 }
14002 }
14003
14004 823592 bool attacked = doattack();
14005
14006 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
14007
10/12
✓ Branch 0 taken 821799 times.
✓ Branch 1 taken 1793 times.
✓ Branch 2 taken 582289 times.
✓ Branch 3 taken 239510 times.
✓ Branch 4 taken 111754 times.
✓ Branch 5 taken 470535 times.
✓ Branch 6 taken 110078 times.
✓ Branch 7 taken 1676 times.
✓ Branch 8 taken 110078 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 110078 times.
823592 if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
14008 {
14009
4/4
✓ Branch 0 taken 47006 times.
✓ Branch 1 taken 63072 times.
✓ Branch 2 taken 4695 times.
✓ Branch 3 taken 42311 times.
110078 if((xoff==0)||diagonalMovement)
14010 {
14011
2/2
✓ Branch 0 taken 60798 times.
✓ Branch 1 taken 6969 times.
67767 if(DrunkUp()) dir=up;
14012
14013
2/2
✓ Branch 0 taken 60507 times.
✓ Branch 1 taken 7260 times.
67767 if(DrunkDown()) dir=down;
14014 67767 }
14015
14016
4/4
✓ Branch 0 taken 35391 times.
✓ Branch 1 taken 74687 times.
✓ Branch 2 taken 3273 times.
✓ Branch 3 taken 32118 times.
110078 if((yoff==0)||diagonalMovement)
14017 {
14018
2/2
✓ Branch 0 taken 68675 times.
✓ Branch 1 taken 9285 times.
77960 if(DrunkLeft()) dir=left;
14019
14020
2/2
✓ Branch 0 taken 68894 times.
✓ Branch 1 taken 9066 times.
77960 if(DrunkRight()) dir=right;
14021 77960 }
14022 110078 }
14023
14024
9/10
✓ Branch 0 taken 765877 times.
✓ Branch 1 taken 57715 times.
✓ Branch 2 taken 763956 times.
✓ Branch 3 taken 1921 times.
✓ Branch 4 taken 763521 times.
✓ Branch 5 taken 435 times.
✓ Branch 6 taken 759306 times.
✓ Branch 7 taken 4215 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 759306 times.
823592 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
14025 {
14026 759306 return;
14027 }
14028
2/2
✓ Branch 0 taken 6571 times.
✓ Branch 1 taken 57715 times.
64286 else if(!attacked)
14029 {
14030 // Spin attack - change direction
14031
3/4
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 57467 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 248 times.
57715 if(spins>1 && attack != wHammer)
14032 {
14033 248 spins--;
14034
14035
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 45 times.
248 if(spins%5==0)
14036 {
14037
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 int id = currentscroll > -1 ? currentscroll : (current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll));
14038 45 sfx(itemsbuf[id].usesound,pan(x.getInt()));
14039 45 }
14040 248 attackclk=1;
14041
14042
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 62 times.
248 switch(dir)
14043 {
14044 case up:
14045 62 dir=left;
14046 62 break;
14047
14048 case right:
14049 62 dir=up;
14050 62 break;
14051
14052 case down:
14053 62 dir=right;
14054 62 break;
14055
14056 case left:
14057 62 dir=down;
14058 62 break;
14059 }
14060
14061 248 return;
14062 }
14063 else
14064 {
14065 57467 spins=0;
14066 }
14067
14068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57467 times.
57467 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
14069 57467 else {action=none; FFCore.setHeroAction(none);}
14070 57467 attackclk=0;
14071 57467 charging=0;
14072 57467 }
14073 64038 }
14074
14075
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5355225 times.
5355228 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
14076 3 return;
14077
14078
2/2
✓ Branch 0 taken 2203764 times.
✓ Branch 1 taken 3151461 times.
5355225 if(action==walking) //still walking
14079 {
14080
9/10
✓ Branch 0 taken 2379942 times.
✓ Branch 1 taken 771519 times.
✓ Branch 2 taken 1752551 times.
✓ Branch 3 taken 627391 times.
✓ Branch 4 taken 934279 times.
✓ Branch 5 taken 818272 times.
✓ Branch 6 taken 40975 times.
✓ Branch 7 taken 893304 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 40975 times.
3151461 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
14081 {
14082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40975 times.
40975 if(attackclk>0) SetAttack();
14083 40975 else {action = none; FFCore.setHeroAction(none);}
14084 40975 hero_count=-1;
14085 40975 return;
14086 }
14087
14088 3110486 autostep=false;
14089
14090
4/6
✓ Branch 0 taken 2811935 times.
✓ Branch 1 taken 298551 times.
✓ Branch 2 taken 2811935 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2811935 times.
3110486 if(!(diagonalMovement || NO_GRIDLOCK))
14091 {
14092
2/4
✓ Branch 0 taken 2811935 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2811935 times.
2811935 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
14093 {
14094 if(dir==up&&yoff)
14095 {
14096 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
14097 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
14098 execute(info);
14099
14100 if(!info.isUnwalkable())
14101 {
14102 moveOld2(up);
14103 }
14104 else
14105 {
14106 action=none; FFCore.setHeroAction(none);
14107 }
14108
14109 return;
14110 }
14111
14112 if(dir==down&&yoff)
14113 {
14114 info = walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
14115 info = info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7]));
14116 execute(info);
14117
14118 if(!info.isUnwalkable())
14119 {
14120 moveOld2(down);
14121 }
14122 else
14123 {
14124 action=none; FFCore.setHeroAction(none);
14125 }
14126
14127 return;
14128 }
14129
14130 if(dir==left&&xoff)
14131 {
14132 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) || walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
14133 execute(info);
14134
14135 if(!info.isUnwalkable())
14136 {
14137 moveOld2(left);
14138 }
14139 else
14140 {
14141 action=none; FFCore.setHeroAction(none);
14142 }
14143
14144 return;
14145 }
14146
14147 if(dir==right&&xoff)
14148 {
14149 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
14150 execute(info);
14151
14152 if(!info.isUnwalkable())
14153 {
14154 moveOld2(right);
14155 }
14156 else
14157 {
14158 action=none; FFCore.setHeroAction(none);
14159 }
14160
14161 return;
14162 }
14163 }
14164 else
14165 {
14166
4/4
✓ Branch 0 taken 651566 times.
✓ Branch 1 taken 2160369 times.
✓ Branch 2 taken 107118 times.
✓ Branch 3 taken 544448 times.
2811935 if(dir==up&&yoff)
14167 {
14168 544448 while(true)
14169 {
14170 544448 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
14171 544448 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
14172 544448 execute(info);
14173
14174
2/2
✓ Branch 0 taken 2253 times.
✓ Branch 1 taken 542195 times.
544448 if(!info.isUnwalkable())
14175 {
14176 542195 hero_newstep = temp_step;
14177 542195 x = temp_x;
14178 542195 y = temp_y;
14179 542195 moveOld2(up);
14180 542195 return;
14181 }
14182 //Could not move, try moving less
14183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2253 times.
2253 if(temp_y != int32_t(temp_y))
14184 {
14185 temp_y = floor((double)temp_y);
14186 continue;
14187 }
14188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2253 times.
2253 else if(temp_step > 1)
14189 {
14190 if(temp_step != int32_t(temp_step)) //floor
14191 temp_step = floor((double)temp_step);
14192 else --temp_step;
14193 continue;
14194 }
14195 else //Can't move less, stop moving
14196 {
14197 2253 action=none; FFCore.setHeroAction(none);
14198 }
14199 2253 return;
14200 }
14201 }
14202
14203
4/4
✓ Branch 0 taken 532581 times.
✓ Branch 1 taken 1734906 times.
✓ Branch 2 taken 88217 times.
✓ Branch 3 taken 444364 times.
2267487 if(dir==down&&yoff)
14204 {
14205 444364 while(true)
14206 {
14207 444371 info = walkflag(temp_x,temp_y+15+temp_step,2,down);
14208 444371 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
14209 444371 execute(info);
14210
14211
2/2
✓ Branch 0 taken 1863 times.
✓ Branch 1 taken 442508 times.
444371 if(!info.isUnwalkable())
14212 {
14213 442508 hero_newstep = temp_step;
14214 442508 x = temp_x;
14215 442508 y = temp_y;
14216 442508 moveOld2(down);
14217 442508 return;
14218 }
14219 //Could not move, try moving less
14220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1863 times.
1863 if(temp_y != int32_t(temp_y))
14221 {
14222 temp_y = floor((double)temp_y);
14223 continue;
14224 }
14225
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1856 times.
1863 else if(temp_step > 1)
14226 {
14227
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(temp_step != int32_t(temp_step)) //floor
14228 7 temp_step = floor((double)temp_step);
14229 else --temp_step;
14230 7 continue;
14231 }
14232 else //Can't move less, stop moving
14233 {
14234 1856 action=none; FFCore.setHeroAction(none);
14235 }
14236 1856 return;
14237 }
14238 }
14239
14240
4/4
✓ Branch 0 taken 785030 times.
✓ Branch 1 taken 1038093 times.
✓ Branch 2 taken 131818 times.
✓ Branch 3 taken 653212 times.
1823123 if(dir==left&&xoff)
14241 {
14242 653212 while(true)
14243 {
14244 653212 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) || walkflag(temp_x-temp_step,temp_y+8,1,left);
14245 653212 execute(info);
14246
14247
2/2
✓ Branch 0 taken 2018 times.
✓ Branch 1 taken 651194 times.
653212 if(!info.isUnwalkable())
14248 {
14249 651194 hero_newstep = temp_step;
14250 651194 x = temp_x;
14251 651194 y = temp_y;
14252 651194 moveOld2(left);
14253 651194 return;
14254 }
14255 //Could not move, try moving less
14256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2018 times.
2018 if(temp_x != int32_t(temp_x))
14257 {
14258 temp_x = floor((double)temp_x);
14259 continue;
14260 }
14261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2018 times.
2018 else if(temp_step > 1)
14262 {
14263 if(temp_step != int32_t(temp_step)) //floor
14264 temp_step = floor((double)temp_step);
14265 else --temp_step;
14266 continue;
14267 }
14268 else //Can't move less, stop moving
14269 {
14270 2018 action=none; FFCore.setHeroAction(none);
14271 }
14272 2018 return;
14273 }
14274 }
14275
14276
4/4
✓ Branch 0 taken 842758 times.
✓ Branch 1 taken 327153 times.
✓ Branch 2 taken 141190 times.
✓ Branch 3 taken 701568 times.
1169911 if(dir==right&&xoff)
14277 {
14278 701568 while(true)
14279 {
14280 701576 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) || walkflag(temp_x+15+temp_step,temp_y+8,1,right);
14281 701576 execute(info);
14282
14283
2/2
✓ Branch 0 taken 2007 times.
✓ Branch 1 taken 699569 times.
701576 if(!info.isUnwalkable())
14284 {
14285 699569 hero_newstep = temp_step;
14286 699569 x = temp_x;
14287 699569 y = temp_y;
14288 699569 moveOld2(right);
14289 699569 return;
14290 }
14291 //Could not move, try moving less
14292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2007 times.
2007 if(temp_x != int32_t(temp_x))
14293 {
14294 temp_x = floor((double)temp_x);
14295 continue;
14296 }
14297
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1999 times.
2007 else if(temp_step > 1)
14298 {
14299
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(temp_step != int32_t(temp_step)) //floor
14300 8 temp_step = floor((double)temp_step);
14301 else --temp_step;
14302 8 continue;
14303 }
14304 else //Can't move less, stop moving
14305 {
14306 1999 action=none; FFCore.setHeroAction(none);
14307 }
14308 1999 return;
14309 }
14310 }
14311 }
14312 468343 }
14313
14314 766894 } // endif (action==walking)
14315
14316
16/24
✓ Branch 0 taken 2906456 times.
✓ Branch 1 taken 64202 times.
✓ Branch 2 taken 2906456 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2906456 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2906456 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2906456 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2906456 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2906456 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2906456 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 2906456 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 2904535 times.
✓ Branch 19 taken 1921 times.
✓ Branch 20 taken 2904100 times.
✓ Branch 21 taken 435 times.
✓ Branch 22 taken 74093 times.
✓ Branch 23 taken 2830007 times.
2970658 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
14317 {
14318 2830007 action=none; FFCore.setHeroAction(none);
14319 2830007 }
14320
14321
2/2
✓ Branch 0 taken 639614 times.
✓ Branch 1 taken 2331044 times.
2970658 if(diagonalMovement)
14322 {
14323
5/5
✓ Branch 0 taken 242736 times.
✓ Branch 1 taken 59676 times.
✓ Branch 2 taken 44775 times.
✓ Branch 3 taken 133996 times.
✓ Branch 4 taken 158431 times.
639614 switch(holddir)
14324 {
14325 case up:
14326
2/2
✓ Branch 0 taken 57716 times.
✓ Branch 1 taken 1960 times.
59676 if(!Up())
14327 {
14328 1960 holddir=-1;
14329 1960 }
14330
14331 59676 break;
14332
14333 case down:
14334
2/2
✓ Branch 0 taken 42997 times.
✓ Branch 1 taken 1778 times.
44775 if(!Down())
14335 {
14336 1778 holddir=-1;
14337 1778 }
14338
14339 44775 break;
14340
14341 case left:
14342
2/2
✓ Branch 0 taken 129930 times.
✓ Branch 1 taken 4066 times.
133996 if(!Left())
14343 {
14344 4066 holddir=-1;
14345 4066 }
14346
14347 133996 break;
14348
14349 case right:
14350
2/2
✓ Branch 0 taken 153944 times.
✓ Branch 1 taken 4487 times.
158431 if(!Right())
14351 {
14352 4487 holddir=-1;
14353 4487 }
14354
14355 158431 break;
14356
14357 default:
14358 242736 break;
14359 } //end switch
14360
14361
3/4
✓ Branch 0 taken 513820 times.
✓ Branch 1 taken 125794 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 513820 times.
639614 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim()) //!DIRECTION SET
14362 {
14363 125794 walkable = false;
14364
6/6
✓ Branch 0 taken 22665 times.
✓ Branch 1 taken 103129 times.
✓ Branch 2 taken 21949 times.
✓ Branch 3 taken 716 times.
✓ Branch 4 taken 5910 times.
✓ Branch 5 taken 16039 times.
125794 if(DrunkUp()&&(holddir==-1||holddir==up))
14365 {
14366
4/8
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 16669 times.
✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 86 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
16755 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14367 {
14368 }
14369 else
14370 {
14371
4/10
✓ Branch 0 taken 16755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16755 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16755 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 16755 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
16755 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
14372 {
14373 16755 dir=up;
14374 16755 }
14375
14376 16755 holddir=up;
14377
14378
3/4
✓ Branch 0 taken 1963 times.
✓ Branch 1 taken 14792 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1963 times.
16755 if(DrunkRight()&&shiftdir!=left)
14379 {
14380 1963 shiftdir=right;
14381
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1963 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1963 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
14382
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1963 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1963 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
14383 1963 }
14384
4/4
✓ Branch 0 taken 2117 times.
✓ Branch 1 taken 12675 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2115 times.
14792 else if(DrunkLeft()&&shiftdir!=right)
14385 {
14386 2115 shiftdir=left;
14387
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2115 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
14388
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2115 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
14389 2115 }
14390 else
14391 {
14392 12677 shiftdir=-1;
14393 }
14394
14395 //walkable if Ladder can be placed or is already placed vertically
14396
1/20
✗ Branch 0 not taken.
✓ Branch 1 taken 16755 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
16755 if(isSideViewHero() && !toogam && (!get_bit(quest_rules, qr_OLD_LADDER_ITEM_SIDEVIEW) || !(can_deploy_ladder() || (ladderx && laddery && ladderdir==up))) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14397 {
14398 walkable=false;
14399 }
14400 else
14401 {
14402 16755 do
14403 {
14404 19269 zfix ty = y - hero_newstep;
14405 38538 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
14406 19269 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
14407
14408
3/4
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 19222 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
19269 if (ty < 0 && !bigHitbox) //sanity check for up scroll
14409 {
14410 47 info = info || walkflag(x, zfix(0), 2, up);
14411 47 info = info || walkflag(x+15, zfix(0), 1, up);
14412 47 }
14413 19269 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
14414
14415 19269 execute(info);
14416
14417
2/2
✓ Branch 0 taken 4834 times.
✓ Branch 1 taken 14435 times.
19269 if(info.isUnwalkable())
14418 {
14419
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 4640 times.
4834 if(y != y.getInt())
14420 {
14421 194 y.doRound();
14422 194 }
14423
2/2
✓ Branch 0 taken 2320 times.
✓ Branch 1 taken 2320 times.
4640 else if(hero_newstep > 1)
14424 {
14425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2320 times.
2320 if(hero_newstep != int32_t(hero_newstep)) //floor
14426 2320 hero_newstep = floor((double)hero_newstep);
14427 else --hero_newstep;
14428 2320 }
14429 else
14430 2320 break;
14431 2514 }
14432 14435 else walkable = true;
14433
2/2
✓ Branch 0 taken 2514 times.
✓ Branch 1 taken 14435 times.
16949 }
14434 16949 while(!walkable);
14435 }
14436
14437 16755 int32_t s=shiftdir;
14438
14439
4/6
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 16669 times.
✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86 times.
✗ Branch 5 not taken.
16755 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
14440 {
14441 shiftdir=-1;
14442 }
14443 else
14444 {
14445
2/2
✓ Branch 0 taken 2115 times.
✓ Branch 1 taken 14640 times.
16755 if(s==left)
14446 {
14447 2115 do
14448 {
14449 2513 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
14450
14451 2513 execute(info);
14452
14453
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 1753 times.
2513 if(info.isUnwalkable())
14454 {
14455
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 724 times.
760 if(x != x.getInt())
14456 {
14457 36 x.doRound();
14458 36 }
14459
2/2
✓ Branch 0 taken 362 times.
✓ Branch 1 taken 362 times.
724 else if(hero_newstep_diag > 1)
14460 {
14461
1/2
✓ Branch 0 taken 362 times.
✗ Branch 1 not taken.
362 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14462 362 hero_newstep_diag.doFloor();
14463 else --hero_newstep_diag;
14464 362 }
14465 else
14466 362 shiftdir = -1;
14467 760 }
14468
2/2
✓ Branch 0 taken 1523 times.
✓ Branch 1 taken 230 times.
1753 else if(walkable)
14469 {
14470 1523 do
14471 {
14472 1526 info = walkflag(x-hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,left);
14473 1526 execute(info);
14474
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1521 times.
1526 if(info.isUnwalkable())
14475 {
14476
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
5 if(x != x.getInt())
14477 {
14478 1 x.doRound();
14479 1 }
14480
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(hero_newstep_diag > 1)
14481 {
14482
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14483 2 hero_newstep_diag.doFloor();
14484 else --hero_newstep_diag;
14485 2 }
14486 else
14487 2 shiftdir = -1;
14488 5 }
14489 1521 else break;
14490
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 }
14491 5 while(shiftdir != -1);
14492 1523 break;
14493 }
14494 230 else break;
14495
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 362 times.
760 }
14496 760 while(shiftdir != -1);
14497 2115 }
14498
2/2
✓ Branch 0 taken 12677 times.
✓ Branch 1 taken 1963 times.
14640 else if(s==right)
14499 {
14500 1963 do
14501 {
14502 2269 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
14503
14504 2269 execute(info);
14505
14506
2/2
✓ Branch 0 taken 577 times.
✓ Branch 1 taken 1692 times.
2269 if(info.isUnwalkable())
14507 {
14508
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 542 times.
577 if(x != x.getInt())
14509 {
14510 35 x.doRound();
14511 35 }
14512
2/2
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 271 times.
542 else if(hero_newstep_diag > 1)
14513 {
14514
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14515 271 hero_newstep_diag.doFloor();
14516 else --hero_newstep_diag;
14517 271 }
14518 else
14519 271 shiftdir = -1;
14520 577 }
14521
2/2
✓ Branch 0 taken 1467 times.
✓ Branch 1 taken 225 times.
1692 else if(walkable)
14522 {
14523 1467 do
14524 {
14525 1473 info = walkflag(x+15+hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,right);
14526 1473 execute(info);
14527
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1462 times.
1473 if(info.isUnwalkable())
14528 {
14529
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if(x != x.getInt())
14530 {
14531 1 x.doRound();
14532 1 }
14533
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
10 else if(hero_newstep_diag > 1)
14534 {
14535
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14536 5 hero_newstep_diag.doFloor();
14537 else --hero_newstep_diag;
14538 5 }
14539 else
14540 5 shiftdir = -1;
14541 11 }
14542 1462 else break;
14543
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
11 }
14544 11 while(shiftdir != -1);
14545 1467 break;
14546 }
14547 225 else break;
14548
2/2
✓ Branch 0 taken 306 times.
✓ Branch 1 taken 271 times.
577 }
14549 577 while(shiftdir != -1);
14550 1963 }
14551 }
14552
14553 16755 moveOld2(up);
14554 16755 shiftdir=s;
14555
14556
2/2
✓ Branch 0 taken 14435 times.
✓ Branch 1 taken 2320 times.
16755 if(!walkable)
14557 {
14558
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 1794 times.
2320 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14559 {
14560 1794 x = x.getInt();
14561 1794 y = y.getInt();
14562
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1794 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1794 times.
✓ Branch 4 taken 1541 times.
✓ Branch 5 taken 253 times.
✓ Branch 6 taken 116 times.
✓ Branch 7 taken 1678 times.
2047 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14563
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 253 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 253 times.
✓ Branch 4 taken 130 times.
✓ Branch 5 taken 123 times.
253 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14564
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
✓ Branch 2 taken 123 times.
✗ Branch 3 not taken.
123 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14565 {
14566
5/8
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 112 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 116 times.
116 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
14567 116 sprite::move((zfix)-1,(zfix)0);
14568 116 }
14569 else
14570 {
14571
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1678 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1678 times.
✓ Branch 4 taken 137 times.
✓ Branch 5 taken 1541 times.
✓ Branch 6 taken 126 times.
✓ Branch 7 taken 1552 times.
3219 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14572
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1541 times.
✓ Branch 2 taken 1541 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1415 times.
✓ Branch 5 taken 126 times.
1541 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14573
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
126 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14574 {
14575
4/8
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 126 times.
126 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
14576 126 sprite::move((zfix)1,(zfix)0);
14577 126 }
14578 else
14579 {
14580 1552 pushing=push+1;
14581 }
14582 }
14583 1794 }
14584 else
14585 {
14586 526 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14587 }
14588 2320 }
14589
14590 16755 return;
14591 }
14592 }
14593
14594
6/6
✓ Branch 0 taken 21576 times.
✓ Branch 1 taken 87463 times.
✓ Branch 2 taken 20782 times.
✓ Branch 3 taken 794 times.
✓ Branch 4 taken 15489 times.
✓ Branch 5 taken 5293 times.
109039 if(DrunkDown()&&(holddir==-1||holddir==down))
14595 {
14596
4/8
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 16150 times.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 133 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
16283 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14597 {
14598 }
14599 else
14600 {
14601
4/10
✓ Branch 0 taken 16283 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16283 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16283 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 16283 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
16283 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
14602 {
14603 16283 dir=down;
14604 16283 }
14605
14606 16283 holddir=down;
14607
14608
4/4
✓ Branch 0 taken 2430 times.
✓ Branch 1 taken 13853 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2428 times.
16283 if(DrunkRight()&&shiftdir!=left)
14609 {
14610 2428 shiftdir=right;
14611
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2428 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2428 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
14612
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2428 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2428 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
14613 2428 }
14614
4/4
✓ Branch 0 taken 2498 times.
✓ Branch 1 taken 11357 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2497 times.
13855 else if(DrunkLeft()&&shiftdir!=right)
14615 {
14616 2497 shiftdir=left;
14617
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2497 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2497 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
14618
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2497 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2497 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
14619 2497 }
14620 else
14621 {
14622 11358 shiftdir=-1;
14623 }
14624
14625 //bool walkable;
14626
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 16283 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
16283 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14627 {
14628 walkable=false;
14629 }
14630 else
14631 {
14632 16283 do
14633 {
14634 18121 info = walkflag(x,15+(y+hero_newstep),2,down);
14635
14636
2/2
✓ Branch 0 taken 10414 times.
✓ Branch 1 taken 7707 times.
18121 if(x.getFloor() & 7)
14637 10414 info = info || walkflag(x+15,15+(y+hero_newstep),1,down);
14638 else
14639 7707 info = info || walkflagMBlock(x+15, 15+(y+hero_newstep));
14640
14641 18121 execute(info);
14642
14643
2/2
✓ Branch 0 taken 3449 times.
✓ Branch 1 taken 14672 times.
18121 if(info.isUnwalkable())
14644 {
14645
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 3234 times.
3449 if(y != y.getInt())
14646 {
14647 215 y.doRound();
14648 215 }
14649
2/2
✓ Branch 0 taken 1623 times.
✓ Branch 1 taken 1611 times.
3234 else if(hero_newstep > 1)
14650 {
14651
1/2
✓ Branch 0 taken 1623 times.
✗ Branch 1 not taken.
1623 if(hero_newstep != int32_t(hero_newstep)) //floor
14652 1623 hero_newstep = floor((double)hero_newstep);
14653 else --hero_newstep;
14654 1623 }
14655 else
14656 1611 break;
14657 1838 }
14658 14672 else walkable = true;
14659
2/2
✓ Branch 0 taken 1838 times.
✓ Branch 1 taken 14672 times.
16510 }
14660 16510 while(!walkable);
14661 }
14662
14663 16283 int32_t s=shiftdir;
14664
14665
4/6
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 16150 times.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
16283 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
14666 {
14667 shiftdir=-1;
14668 }
14669 else
14670 {
14671
2/2
✓ Branch 0 taken 2497 times.
✓ Branch 1 taken 13786 times.
16283 if(s==left)
14672 {
14673 2497 do
14674 {
14675 2882 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
14676
14677 2882 execute(info);
14678
14679
2/2
✓ Branch 0 taken 718 times.
✓ Branch 1 taken 2164 times.
2882 if(info.isUnwalkable())
14680 {
14681
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 666 times.
718 if(x != x.getInt())
14682 {
14683 52 x.doRound();
14684 52 }
14685
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 333 times.
666 else if(hero_newstep_diag > 1)
14686 {
14687
1/2
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
333 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14688 333 hero_newstep_diag.doFloor();
14689 else --hero_newstep_diag;
14690 333 }
14691 else
14692 333 shiftdir = -1;
14693 718 }
14694
2/2
✓ Branch 0 taken 1922 times.
✓ Branch 1 taken 242 times.
2164 else if(walkable)
14695 {
14696 1922 do
14697 {
14698 1929 info = walkflag(x-hero_newstep_diag,15+(y+hero_newstep),1,left);
14699 1929 execute(info);
14700
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1919 times.
1929 if(info.isUnwalkable())
14701 {
14702
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 6 times.
10 if(x != x.getInt())
14703 {
14704 4 x.doRound();
14705 4 }
14706
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 else if(hero_newstep_diag > 1)
14707 {
14708
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14709 3 hero_newstep_diag.doFloor();
14710 else --hero_newstep_diag;
14711 3 }
14712 else
14713 3 shiftdir = -1;
14714 10 }
14715 1919 else break;
14716
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
10 }
14717 10 while(shiftdir != -1);
14718 1922 break;
14719 }
14720 242 else break;
14721
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 333 times.
718 }
14722 718 while(shiftdir != -1);
14723 2497 }
14724
2/2
✓ Branch 0 taken 11358 times.
✓ Branch 1 taken 2428 times.
13786 else if(s==right)
14725 {
14726 2428 do
14727 {
14728 2754 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
14729
14730 2754 execute(info);
14731
14732
2/2
✓ Branch 0 taken 628 times.
✓ Branch 1 taken 2126 times.
2754 if(info.isUnwalkable())
14733 {
14734
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 604 times.
628 if(x != x.getInt())
14735 {
14736 24 x.doRound();
14737 24 }
14738
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 302 times.
604 else if(hero_newstep_diag > 1)
14739 {
14740
1/2
✓ Branch 0 taken 302 times.
✗ Branch 1 not taken.
302 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14741 302 hero_newstep_diag.doFloor();
14742 else --hero_newstep_diag;
14743 302 }
14744 else
14745 302 shiftdir = -1;
14746 628 }
14747
2/2
✓ Branch 0 taken 1875 times.
✓ Branch 1 taken 251 times.
2126 else if(walkable)
14748 {
14749 1875 do
14750 {
14751 1879 info = walkflag(x+15+hero_newstep_diag,15+(y+hero_newstep),1,right);
14752 1879 execute(info);
14753
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1871 times.
1879 if(info.isUnwalkable())
14754 {
14755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(x != x.getInt())
14756 {
14757 x.doRound();
14758 }
14759
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
8 else if(hero_newstep_diag > 1)
14760 {
14761
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14762 4 hero_newstep_diag.doFloor();
14763 else --hero_newstep_diag;
14764 4 }
14765 else
14766 4 shiftdir = -1;
14767 8 }
14768 1871 else break;
14769
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
8 }
14770 8 while(shiftdir != -1);
14771 1875 break;
14772 }
14773 251 else break;
14774
2/2
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 302 times.
628 }
14775 628 while(shiftdir != -1);
14776 2428 }
14777 }
14778
14779 16283 moveOld2(down);
14780 16283 shiftdir=s;
14781
14782
2/2
✓ Branch 0 taken 14672 times.
✓ Branch 1 taken 1611 times.
16283 if(!walkable)
14783 {
14784
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 1088 times.
1611 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14785 {
14786 1088 x = x.getInt();
14787 1088 y = y.getInt();
14788
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1088 times.
✓ Branch 2 taken 1088 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 905 times.
✓ Branch 5 taken 183 times.
✓ Branch 6 taken 131 times.
✓ Branch 7 taken 957 times.
1271 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
14789
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 183 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 131 times.
183 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
14790
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
✓ Branch 2 taken 131 times.
✗ Branch 3 not taken.
131 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
14791 {
14792
4/8
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 131 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 131 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 131 times.
131 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
14793 131 sprite::move((zfix)-1,(zfix)0);
14794 131 }
14795
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 957 times.
✓ Branch 2 taken 957 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 905 times.
✓ Branch 6 taken 146 times.
✓ Branch 7 taken 811 times.
1862 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
14796
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 905 times.
✓ Branch 2 taken 905 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 759 times.
✓ Branch 5 taken 146 times.
905 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
14797
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 146 times.
146 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
14798 {
14799
4/8
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 146 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 146 times.
146 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
14800 146 sprite::move((zfix)1,(zfix)0);
14801 146 }
14802 else
14803 {
14804 811 pushing=push+1;
14805 }
14806 1088 }
14807 else
14808 {
14809 523 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14810 }
14811 1611 }
14812
14813 16283 return;
14814 }
14815 }
14816
14817
6/6
✓ Branch 0 taken 22744 times.
✓ Branch 1 taken 70012 times.
✓ Branch 2 taken 21903 times.
✓ Branch 3 taken 841 times.
✓ Branch 4 taken 21895 times.
✓ Branch 5 taken 8 times.
92756 if(DrunkLeft()&&(holddir==-1||holddir==left))
14818 {
14819
4/8
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 22679 times.
✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 57 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
22736 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14820 {
14821 }
14822 else
14823 {
14824
3/6
✓ Branch 0 taken 22736 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22736 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22736 times.
22736 if(charging==0 && spins==0 && action != sideswimattacking)
14825 {
14826 22736 dir=left;
14827 22736 }
14828 22736 sideswimdir = left;
14829
14830 22736 holddir=left;
14831
14832
3/4
✓ Branch 0 taken 3139 times.
✓ Branch 1 taken 19597 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3139 times.
22736 if(DrunkUp()&&shiftdir!=down)
14833 {
14834 3139 shiftdir=up;
14835 3139 }
14836
3/4
✓ Branch 0 taken 2525 times.
✓ Branch 1 taken 17072 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2525 times.
19597 else if(DrunkDown()&&shiftdir!=up)
14837 {
14838 2525 shiftdir=down;
14839 2525 }
14840 else
14841 {
14842 17072 shiftdir=-1;
14843 }
14844
14845 22736 do
14846 {
14847 25350 info = walkflag(x-hero_newstep,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep,y+8,1,left);
14848
14849 25350 info = info || walkflag(x-hero_newstep,y+15,1,left);
14850
14851 25350 execute(info);
14852
14853
2/2
✓ Branch 0 taken 5019 times.
✓ Branch 1 taken 20331 times.
25350 if(info.isUnwalkable())
14854 {
14855
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 4810 times.
5019 if(x != x.getInt())
14856 {
14857 209 x.doRound();
14858 209 }
14859
2/2
✓ Branch 0 taken 2405 times.
✓ Branch 1 taken 2405 times.
4810 else if(hero_newstep > 1)
14860 {
14861
1/2
✓ Branch 0 taken 2405 times.
✗ Branch 1 not taken.
2405 if(hero_newstep != int32_t(hero_newstep)) //floor
14862 2405 hero_newstep = floor((double)hero_newstep);
14863 else --hero_newstep;
14864 2405 }
14865 else
14866 2405 break;
14867 2614 }
14868 20331 else walkable = true;
14869
2/2
✓ Branch 0 taken 2614 times.
✓ Branch 1 taken 20331 times.
22945 }
14870 22945 while(!walkable);
14871
14872 22736 int32_t s=shiftdir;
14873
14874
5/14
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 22679 times.
✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 57 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 22736 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
22736 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
14875 {
14876 shiftdir=-1;
14877 }
14878 else
14879 {
14880
2/2
✓ Branch 0 taken 19597 times.
✓ Branch 1 taken 3139 times.
22736 if(s==up)
14881 {
14882 3139 do
14883 {
14884 3609 zfix ty = y - hero_newstep_diag;
14885 7218 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
14886 3609 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
14887
14888
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3608 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
3609 if (ty < 0 && !bigHitbox) //sanity check for up scroll
14889 {
14890 1 info = info || walkflag(x, zfix(0), 2, up);
14891 1 info = info || walkflag(x+15, zfix(0), 1, up);
14892 1 }
14893 3609 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
14894
14895 3609 execute(info);
14896
14897
2/2
✓ Branch 0 taken 895 times.
✓ Branch 1 taken 2714 times.
3609 if(info.isUnwalkable())
14898 {
14899
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 850 times.
895 if(y != y.getInt())
14900 {
14901 45 y.doRound();
14902 45 }
14903
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 425 times.
850 else if(hero_newstep_diag > 1)
14904 {
14905
1/2
✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
425 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14906 425 hero_newstep_diag.doFloor();
14907 else --hero_newstep_diag;
14908 425 }
14909 else
14910 425 shiftdir = -1;
14911 895 }
14912
2/2
✓ Branch 0 taken 2197 times.
✓ Branch 1 taken 517 times.
2714 else if(walkable)
14913 {
14914 2197 do
14915 {
14916 2219 zfix tx = x-hero_newstep, ty = y-hero_newstep_diag;
14917 2219 info = walkflag(tx,(bigHitbox?0:8)+ty,1,up);
14918
14919
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2218 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
2219 if (ty < 0 && !bigHitbox) //sanity check for up scroll
14920 {
14921 1 info = info || walkflag(tx, zfix(0), 1, up);
14922 1 info = info || walkflag(tx+15, zfix(0), 1, up);
14923 1 }
14924 2219 info = info || walkflagMBlock(tx+15, (bigHitbox?0:8) + ty);
14925
14926 2219 execute(info);
14927
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 2184 times.
2219 if(info.isUnwalkable())
14928 {
14929
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 26 times.
35 if(y != y.getInt())
14930 {
14931 9 y.doRound();
14932 9 }
14933
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13 times.
26 else if(hero_newstep_diag > 1)
14934 {
14935
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14936 13 hero_newstep_diag.doFloor();
14937 else --hero_newstep_diag;
14938 13 }
14939 else
14940 13 shiftdir = -1;
14941 35 }
14942 2184 else break;
14943
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 13 times.
35 }
14944 35 while(shiftdir != -1);
14945 2197 break;
14946 }
14947 517 else break;
14948
2/2
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 425 times.
895 }
14949 895 while(shiftdir != -1);
14950 3139 }
14951
2/2
✓ Branch 0 taken 17072 times.
✓ Branch 1 taken 2525 times.
19597 else if(s==down)
14952 {
14953 2525 do
14954 {
14955 2960 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
14956
14957 2960 execute(info);
14958
14959
2/2
✓ Branch 0 taken 823 times.
✓ Branch 1 taken 2137 times.
2960 if(info.isUnwalkable())
14960 {
14961
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 776 times.
823 if(y != y.getInt())
14962 {
14963 47 y.doRound();
14964 47 }
14965
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 388 times.
776 else if(hero_newstep_diag > 1)
14966 {
14967
1/2
✓ Branch 0 taken 388 times.
✗ Branch 1 not taken.
388 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14968 388 hero_newstep_diag.doFloor();
14969 else --hero_newstep_diag;
14970 388 }
14971 else
14972 388 shiftdir = -1;
14973 823 }
14974
2/2
✓ Branch 0 taken 1755 times.
✓ Branch 1 taken 382 times.
2137 else if(walkable)
14975 {
14976 1755 do
14977 {
14978 1758 info = walkflag(x-hero_newstep,y+15+hero_newstep_diag,1,down);
14979 1758 execute(info);
14980
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1753 times.
1758 if(info.isUnwalkable())
14981 {
14982
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
5 if(y != y.getInt())
14983 {
14984 1 y.doRound();
14985 1 }
14986
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(hero_newstep_diag > 1)
14987 {
14988
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14989 2 hero_newstep_diag.doFloor();
14990 else --hero_newstep_diag;
14991 2 }
14992 else
14993 2 shiftdir = -1;
14994 5 }
14995 1753 else break;
14996
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 }
14997 5 while(shiftdir != -1);
14998 1755 break;
14999 }
15000 382 else break;
15001
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 388 times.
823 }
15002 823 while(shiftdir != -1);
15003 2525 }
15004 }
15005
15006 22736 moveOld2(left);
15007 22736 shiftdir=s;
15008
15009
2/2
✓ Branch 0 taken 20331 times.
✓ Branch 1 taken 2405 times.
22736 if(!walkable)
15010 {
15011
2/2
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 1434 times.
2405 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15012 {
15013 1434 x = x.getInt();
15014 1434 y = y.getInt();
15015 1434 int32_t v1=bigHitbox?0:8;
15016 1434 int32_t v2=bigHitbox?8:12;
15017
15018
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1434 times.
✓ Branch 2 taken 1434 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1261 times.
✓ Branch 5 taken 173 times.
✓ Branch 6 taken 31 times.
✓ Branch 7 taken 1403 times.
1607 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
15019
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 173 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 173 times.
✓ Branch 4 taken 142 times.
✓ Branch 5 taken 31 times.
173 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
15020
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
31 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
15021 {
15022
4/8
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 31 times.
31 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
15023 31 sprite::move((zfix)0,(zfix)-1);
15024 31 }
15025
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1403 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1403 times.
✓ Branch 4 taken 142 times.
✓ Branch 5 taken 1261 times.
✓ Branch 6 taken 35 times.
✓ Branch 7 taken 1368 times.
2664 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
15026
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1261 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1261 times.
✓ Branch 4 taken 1226 times.
✓ Branch 5 taken 35 times.
1261 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
15027
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
35 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
15028 {
15029
4/8
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 35 times.
35 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
15030 35 sprite::move((zfix)0,(zfix)1);
15031 35 }
15032 else
15033 {
15034 1368 pushing=push+1;
15035 }
15036 1434 }
15037 else
15038 {
15039 971 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15040
15041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 971 times.
971 if(action!=swimming)
15042 {
15043 971 }
15044 }
15045 2405 }
15046
15047 22736 return;
15048 }
15049 }
15050
15051
5/6
✓ Branch 0 taken 24289 times.
✓ Branch 1 taken 45731 times.
✓ Branch 2 taken 23459 times.
✓ Branch 3 taken 830 times.
✓ Branch 4 taken 23459 times.
✗ Branch 5 not taken.
70020 if(DrunkRight()&&(holddir==-1||holddir==right))
15052 {
15053
4/8
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 24131 times.
✓ Branch 2 taken 158 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 158 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
24289 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15054 {
15055 }
15056 else
15057 {
15058
3/6
✓ Branch 0 taken 24289 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24289 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24289 times.
24289 if(charging==0 && spins==0 && action != sideswimattacking)
15059 {
15060 24289 dir=right;
15061 24289 }
15062 24289 sideswimdir = right;
15063
15064 24289 holddir=right;
15065
15066
3/4
✓ Branch 0 taken 2769 times.
✓ Branch 1 taken 21520 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2769 times.
24289 if(DrunkUp()&&shiftdir!=down)
15067 {
15068 2769 shiftdir=up;
15069 2769 }
15070
4/4
✓ Branch 0 taken 2767 times.
✓ Branch 1 taken 18753 times.
✓ Branch 2 taken 2765 times.
✓ Branch 3 taken 2 times.
21520 else if(DrunkDown()&&shiftdir!=up)
15071 {
15072 2765 shiftdir=down;
15073 2765 }
15074 else
15075 {
15076 18755 shiftdir=-1;
15077 }
15078
15079 24289 do
15080 {
15081 26929 info = walkflag(x+15+hero_newstep,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep,y+8,1,right);;
15082
15083 26929 info = info || walkflag(x+15+hero_newstep,y+15,1,right);
15084
15085 26929 execute(info);
15086
15087
2/2
✓ Branch 0 taken 5058 times.
✓ Branch 1 taken 21871 times.
26929 if(info.isUnwalkable())
15088 {
15089
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 4846 times.
5058 if(x != x.getInt())
15090 {
15091 212 x.doRound();
15092 212 }
15093
2/2
✓ Branch 0 taken 2428 times.
✓ Branch 1 taken 2418 times.
4846 else if(hero_newstep > 1)
15094 {
15095
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 if(hero_newstep != int32_t(hero_newstep)) //floor
15096 2428 hero_newstep = floor((double)hero_newstep);
15097 else --hero_newstep;
15098 2428 }
15099 else
15100 2418 break;
15101 2640 }
15102 21871 else walkable = true;
15103
2/2
✓ Branch 0 taken 2640 times.
✓ Branch 1 taken 21871 times.
24511 }
15104 24511 while(!walkable);
15105
15106 24289 int32_t s=shiftdir;
15107
15108
6/14
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 24131 times.
✓ Branch 2 taken 151 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 158 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 24289 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
24289 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15109 {
15110 shiftdir=-1;
15111 }
15112 else
15113 {
15114
2/2
✓ Branch 0 taken 21520 times.
✓ Branch 1 taken 2769 times.
24289 if(s==up)
15115 {
15116 2769 do
15117 {
15118 3053 zfix ty = y - hero_newstep_diag;
15119 6106 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
15120 3053 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
15121
15122
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3053 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3053 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15123 {
15124 info = info || walkflag(x, zfix(0), 2, up);
15125 info = info || walkflag(x+15, zfix(0), 1, up);
15126 }
15127 3053 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
15128
15129 3053 execute(info);
15130
15131
2/2
✓ Branch 0 taken 527 times.
✓ Branch 1 taken 2526 times.
3053 if(info.isUnwalkable())
15132 {
15133
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 486 times.
527 if(y != y.getInt())
15134 {
15135 41 y.doRound();
15136 41 }
15137
2/2
✓ Branch 0 taken 243 times.
✓ Branch 1 taken 243 times.
486 else if(hero_newstep_diag > 1)
15138 {
15139
1/2
✓ Branch 0 taken 243 times.
✗ Branch 1 not taken.
243 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15140 243 hero_newstep_diag.doFloor();
15141 else --hero_newstep_diag;
15142 243 }
15143 else
15144 243 shiftdir = -1;
15145 527 }
15146
2/2
✓ Branch 0 taken 2191 times.
✓ Branch 1 taken 335 times.
2526 else if(walkable)
15147 {
15148 2191 do
15149 {
15150 2210 zfix tx = x+hero_newstep, ty = y-hero_newstep_diag;
15151 2210 info = walkflag(tx+15,(bigHitbox?0:8)+ty,1,up);
15152
15153
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2210 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2210 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15154 {
15155 info = info || walkflag(tx, zfix(0), 1, up);
15156 info = info || walkflag(tx+15, zfix(0), 1, up);
15157 }
15158 2210 info = info || walkflagMBlock(tx+15, (bigHitbox?0:8) + ty);
15159 2210 execute(info);
15160
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 2180 times.
2210 if(info.isUnwalkable())
15161 {
15162
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 22 times.
30 if(y != y.getInt())
15163 {
15164 8 y.doRound();
15165 8 }
15166
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(hero_newstep_diag > 1)
15167 {
15168
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15169 11 hero_newstep_diag.doFloor();
15170 else --hero_newstep_diag;
15171 11 }
15172 else
15173 11 shiftdir = -1;
15174 30 }
15175 2180 else break;
15176
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 11 times.
30 }
15177 30 while(shiftdir != -1);
15178 2191 break;
15179 }
15180 335 else break;
15181
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 243 times.
527 }
15182 527 while(shiftdir != -1);
15183 2769 }
15184
2/2
✓ Branch 0 taken 18755 times.
✓ Branch 1 taken 2765 times.
21520 else if(s==down)
15185 {
15186 2765 do
15187 {
15188 3262 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
15189
15190 3262 execute(info);
15191
15192
2/2
✓ Branch 0 taken 933 times.
✓ Branch 1 taken 2329 times.
3262 if(info.isUnwalkable())
15193 {
15194
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 872 times.
933 if(y != y.getInt())
15195 {
15196 61 y.doRound();
15197 61 }
15198
2/2
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 436 times.
872 else if(hero_newstep_diag > 1)
15199 {
15200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436 times.
436 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15201 436 hero_newstep_diag.doFloor();
15202 else --hero_newstep_diag;
15203 436 }
15204 else
15205 436 shiftdir = -1;
15206 933 }
15207
2/2
✓ Branch 0 taken 1969 times.
✓ Branch 1 taken 360 times.
2329 else if(walkable)
15208 {
15209 1969 do
15210 {
15211 1981 info = walkflag(x+15+hero_newstep,y+15+hero_newstep_diag,1,down);
15212 1981 execute(info);
15213
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1962 times.
1981 if(info.isUnwalkable())
15214 {
15215
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 15 times.
19 if(y != y.getInt())
15216 {
15217 4 y.doRound();
15218 4 }
15219
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 7 times.
15 else if(hero_newstep_diag > 1)
15220 {
15221
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15222 8 hero_newstep_diag.doFloor();
15223 else --hero_newstep_diag;
15224 8 }
15225 else
15226 7 shiftdir = -1;
15227 19 }
15228 1962 else break;
15229
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 7 times.
19 }
15230 19 while(shiftdir != -1);
15231 1969 break;
15232 }
15233 360 else break;
15234
2/2
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 436 times.
933 }
15235 933 while(shiftdir != -1);
15236 2765 }
15237 }
15238
15239 24289 moveOld2(right);
15240 24289 shiftdir=s;
15241
15242
2/2
✓ Branch 0 taken 21871 times.
✓ Branch 1 taken 2418 times.
24289 if(!walkable)
15243 {
15244
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 1668 times.
2418 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15245 {
15246 1668 x = x.getInt();
15247 1668 y = y.getInt();
15248 1668 int32_t v1=bigHitbox?0:8;
15249 1668 int32_t v2=bigHitbox?8:12;
15250
15251
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1668 times.
✓ Branch 2 taken 1668 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1532 times.
✓ Branch 5 taken 136 times.
✓ Branch 6 taken 47 times.
✓ Branch 7 taken 1621 times.
1804 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
15252
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
✓ Branch 2 taken 136 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 89 times.
✓ Branch 5 taken 47 times.
136 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
15253
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
15254 {
15255
4/8
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 47 times.
47 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
15256 47 sprite::move((zfix)0,(zfix)-1);
15257 47 }
15258
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1621 times.
✓ Branch 2 taken 1621 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 89 times.
✓ Branch 5 taken 1532 times.
✓ Branch 6 taken 56 times.
✓ Branch 7 taken 1565 times.
3153 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
15259
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1532 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1532 times.
✓ Branch 4 taken 1476 times.
✓ Branch 5 taken 56 times.
1532 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
15260
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 56 times.
56 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
15261 {
15262
4/8
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 56 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 56 times.
56 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
15263 56 sprite::move((zfix)0,(zfix)1);
15264 56 }
15265 else
15266 {
15267 1565 pushing=push+1;
15268 1565 z3step=2;
15269 }
15270 1668 }
15271 else
15272 {
15273 750 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15274
15275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 750 times.
750 if(action!=swimming)
15276 {
15277 750 }
15278 }
15279 2418 }
15280
15281 24289 return;
15282 }
15283 }
15284 45731 }
15285 else
15286 {
15287
6/6
✓ Branch 0 taken 55400 times.
✓ Branch 1 taken 458420 times.
✓ Branch 2 taken 54153 times.
✓ Branch 3 taken 1247 times.
✓ Branch 4 taken 12476 times.
✓ Branch 5 taken 41677 times.
513820 if(DrunkUp()&&(holddir==-1||holddir==up))
15288 {
15289
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 42924 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
42924 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15290 {
15291 }
15292 else
15293 {
15294
2/4
✓ Branch 0 taken 42924 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42924 times.
42924 if(charging==0 && spins==0)
15295 {
15296 42924 dir=up;
15297 42924 }
15298
15299 42924 holddir=up;
15300
15301
4/4
✓ Branch 0 taken 5386 times.
✓ Branch 1 taken 37538 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 5379 times.
42924 if(DrunkRight()&&shiftdir!=left)
15302 {
15303 5379 shiftdir=right;
15304 5379 }
15305
4/4
✓ Branch 0 taken 4022 times.
✓ Branch 1 taken 33523 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 4016 times.
37545 else if(DrunkLeft()&&shiftdir!=right)
15306 {
15307 4016 shiftdir=left;
15308 4016 }
15309 else
15310 {
15311 33529 shiftdir=-1;
15312 }
15313
15314 //walkable if Ladder can be placed or is already placed vertically
15315
10/18
✓ Branch 0 taken 16485 times.
✓ Branch 1 taken 26439 times.
✓ Branch 2 taken 16485 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16354 times.
✓ Branch 5 taken 131 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 16354 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 16354 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 16354 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 16354 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 16354 times.
42924 if(isSideViewHero() && !toogam && !(can_deploy_ladder() || (ladderx && laddery && ladderdir==up)) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15316 {
15317 16354 walkable=false;
15318 16354 }
15319 else
15320 {
15321 26570 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
15322
15323
2/2
✓ Branch 0 taken 12096 times.
✓ Branch 1 taken 14474 times.
26570 if(x.getInt() & 7)
15324 12096 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
15325 else
15326 14474 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
15327
15328 26570 execute(info);
15329
15330
2/2
✓ Branch 0 taken 3191 times.
✓ Branch 1 taken 23379 times.
26570 if(info.isUnwalkable())
15331 {
15332
2/2
✓ Branch 0 taken 3107 times.
✓ Branch 1 taken 84 times.
3191 if(z3step==2)
15333 {
15334 3107 z3step=1;
15335 3107 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
15336
15337
2/2
✓ Branch 0 taken 1821 times.
✓ Branch 1 taken 1286 times.
3107 if(x.getInt()&7)
15338 1286 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
15339 else
15340 1821 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
15341
15342 3107 execute(info);
15343
15344
2/2
✓ Branch 0 taken 2980 times.
✓ Branch 1 taken 127 times.
3107 if(info.isUnwalkable())
15345 {
15346 2980 walkable = false;
15347 2980 }
15348 else
15349 {
15350 127 walkable=true;
15351 }
15352 3107 }
15353 else
15354 {
15355 84 walkable=false;
15356 }
15357 3191 }
15358 else
15359 {
15360 23379 walkable = true;
15361 }
15362 }
15363
15364 42924 int32_t s=shiftdir;
15365
15366
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 42924 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
42924 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
15367 {
15368 shiftdir=-1;
15369 }
15370 else
15371 {
15372
2/2
✓ Branch 0 taken 4016 times.
✓ Branch 1 taken 38908 times.
42924 if(s==left)
15373 {
15374 4016 info = (walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left));
15375 4016 execute(info);
15376
15377
2/2
✓ Branch 0 taken 511 times.
✓ Branch 1 taken 3505 times.
4016 if(info.isUnwalkable())
15378 {
15379 511 shiftdir=-1;
15380 511 }
15381
2/2
✓ Branch 0 taken 1264 times.
✓ Branch 1 taken 2241 times.
3505 else if(walkable)
15382 {
15383 2241 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,left);
15384 2241 execute(info);
15385
2/2
✓ Branch 0 taken 2238 times.
✓ Branch 1 taken 3 times.
2241 if(info.isUnwalkable())
15386 {
15387 3 shiftdir=-1;
15388 3 }
15389 2241 }
15390 4016 }
15391
2/2
✓ Branch 0 taken 33529 times.
✓ Branch 1 taken 5379 times.
38908 else if(s==right)
15392 {
15393 5379 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
15394 5379 execute(info);
15395
15396
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 4599 times.
5379 if(info.isUnwalkable())
15397 {
15398 780 shiftdir=-1;
15399 780 }
15400
2/2
✓ Branch 0 taken 1732 times.
✓ Branch 1 taken 2867 times.
4599 else if(walkable)
15401 {
15402 2867 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,right);
15403 2867 execute(info);
15404
15405
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 2 times.
2867 if(info.isUnwalkable())
15406 {
15407 2 shiftdir=-1;
15408 2 }
15409 2867 }
15410 5379 }
15411 }
15412
15413 42924 moveOld2(up);
15414 42924 shiftdir=s;
15415
15416
2/2
✓ Branch 0 taken 23506 times.
✓ Branch 1 taken 19418 times.
42924 if(!walkable)
15417 {
15418
2/2
✓ Branch 0 taken 3598 times.
✓ Branch 1 taken 15820 times.
19418 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15419 {
15420
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 15820 times.
✓ Branch 2 taken 15820 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2054 times.
✓ Branch 5 taken 13766 times.
✓ Branch 6 taken 159 times.
✓ Branch 7 taken 15661 times.
29586 if(!_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15421
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13766 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13766 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 13598 times.
13766 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15422
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13598 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13598 times.
13598 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15423 {
15424
5/8
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 147 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 159 times.
159 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
15425 159 sprite::move((zfix)-1,(zfix)0);
15426 159 }
15427 else
15428 {
15429
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 15661 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15661 times.
✓ Branch 4 taken 13607 times.
✓ Branch 5 taken 2054 times.
✓ Branch 6 taken 122 times.
✓ Branch 7 taken 15539 times.
17715 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15430
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2054 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2054 times.
✓ Branch 4 taken 1932 times.
✓ Branch 5 taken 122 times.
2054 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15431
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 122 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 122 times.
122 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15432 {
15433
5/8
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 120 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 122 times.
122 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
15434 122 sprite::move((zfix)1,(zfix)0);
15435 122 }
15436 else
15437 {
15438 15539 pushing=push+1;
15439 }
15440 }
15441
15442 15820 z3step=2;
15443 15820 }
15444 else
15445 {
15446 3598 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15447 3598 z3step=2;
15448 }
15449 19418 }
15450
15451 42924 return;
15452 }
15453 }
15454
15455
6/6
✓ Branch 0 taken 37469 times.
✓ Branch 1 taken 433427 times.
✓ Branch 2 taken 36480 times.
✓ Branch 3 taken 989 times.
✓ Branch 4 taken 27508 times.
✓ Branch 5 taken 8972 times.
470896 if(DrunkDown()&&(holddir==-1||holddir==down))
15456 {
15457
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 28497 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
28497 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15458 {
15459 }
15460 else
15461 {
15462
2/4
✓ Branch 0 taken 28497 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28497 times.
✗ Branch 3 not taken.
28497 if(charging==0 && spins==0)
15463 {
15464 28497 dir=down;
15465 28497 }
15466
15467 28497 holddir=down;
15468
15469
4/4
✓ Branch 0 taken 4174 times.
✓ Branch 1 taken 24323 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4170 times.
28497 if(DrunkRight()&&shiftdir!=left)
15470 {
15471 4170 shiftdir=right;
15472 4170 }
15473
4/4
✓ Branch 0 taken 3439 times.
✓ Branch 1 taken 20888 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3436 times.
24327 else if(DrunkLeft()&&shiftdir!=right)
15474 {
15475 3436 shiftdir=left;
15476 3436 }
15477 else
15478 {
15479 20891 shiftdir=-1;
15480 }
15481
15482 //bool walkable;
15483
7/12
✓ Branch 0 taken 9145 times.
✓ Branch 1 taken 19352 times.
✓ Branch 2 taken 9145 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9145 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9145 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9145 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 9145 times.
28497 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15484 {
15485 9145 walkable=false;
15486 9145 }
15487 else
15488 {
15489 19352 info = walkflag(x,y+15+z3step,2,down);
15490
15491
2/2
✓ Branch 0 taken 9248 times.
✓ Branch 1 taken 10104 times.
19352 if(x.getInt()&7)
15492 9248 info = info || walkflag(x+16,y+15+z3step,1,down);
15493 else
15494 10104 info = info || walkflagMBlock(x+16, y+15+z3step);
15495
15496 19352 execute(info);
15497
15498
2/2
✓ Branch 0 taken 2393 times.
✓ Branch 1 taken 16959 times.
19352 if(info.isUnwalkable())
15499 {
15500
2/2
✓ Branch 0 taken 2327 times.
✓ Branch 1 taken 66 times.
2393 if(z3step==2)
15501 {
15502 2327 z3step=1;
15503 2327 info = walkflag(x,y+15+z3step,2,down);
15504
15505
2/2
✓ Branch 0 taken 1026 times.
✓ Branch 1 taken 1301 times.
2327 if(x.getInt()&7)
15506 1026 info = info || walkflag(x+16,y+15+z3step,1,down);
15507 else
15508 1301 info = info || walkflagMBlock(x+16, y+15+z3step);
15509
15510 2327 execute(info);
15511
15512
2/2
✓ Branch 0 taken 2248 times.
✓ Branch 1 taken 79 times.
2327 if(info.isUnwalkable())
15513 {
15514 2248 walkable = false;
15515 2248 }
15516 else
15517 {
15518 79 walkable=true;
15519 }
15520 2327 }
15521 else
15522 {
15523 66 walkable=false;
15524 }
15525 2393 }
15526 else
15527 {
15528 16959 walkable = true;
15529 }
15530 }
15531
15532 28497 int32_t s=shiftdir;
15533
15534
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 28497 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
28497 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
15535 {
15536 shiftdir=-1;
15537 }
15538 else
15539 {
15540
2/2
✓ Branch 0 taken 3436 times.
✓ Branch 1 taken 25061 times.
28497 if(s==left)
15541 {
15542 3436 info = walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left);
15543 3436 execute(info);
15544
15545
2/2
✓ Branch 0 taken 393 times.
✓ Branch 1 taken 3043 times.
3436 if(info.isUnwalkable())
15546 {
15547 393 shiftdir=-1;
15548 393 }
15549
2/2
✓ Branch 0 taken 1343 times.
✓ Branch 1 taken 1700 times.
3043 else if(walkable)
15550 {
15551 1700 info = walkflag(x-1,y+16,1,left);
15552 1700 execute(info);
15553
15554
2/2
✓ Branch 0 taken 1696 times.
✓ Branch 1 taken 4 times.
1700 if(info.isUnwalkable())
15555 {
15556 4 shiftdir=-1;
15557 4 }
15558 1700 }
15559 3436 }
15560
2/2
✓ Branch 0 taken 20891 times.
✓ Branch 1 taken 4170 times.
25061 else if(s==right)
15561 {
15562 4170 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
15563 4170 execute(info);
15564
15565
2/2
✓ Branch 0 taken 561 times.
✓ Branch 1 taken 3609 times.
4170 if(info.isUnwalkable())
15566 {
15567 561 shiftdir=-1;
15568 561 }
15569
2/2
✓ Branch 0 taken 1112 times.
✓ Branch 1 taken 2497 times.
3609 else if(walkable)
15570 {
15571 2497 info = walkflag(x+16,y+16,1,right);
15572 2497 execute(info);
15573
15574
2/2
✓ Branch 0 taken 2488 times.
✓ Branch 1 taken 9 times.
2497 if(info.isUnwalkable())
15575 {
15576 9 shiftdir=-1;
15577 9 }
15578 2497 }
15579 4170 }
15580 }
15581
15582 28497 moveOld2(down);
15583 28497 shiftdir=s;
15584
15585
2/2
✓ Branch 0 taken 17038 times.
✓ Branch 1 taken 11459 times.
28497 if(!walkable)
15586 {
15587
2/2
✓ Branch 0 taken 2736 times.
✓ Branch 1 taken 8723 times.
11459 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15588 {
15589
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8723 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8723 times.
✓ Branch 4 taken 3004 times.
✓ Branch 5 taken 5719 times.
✓ Branch 6 taken 115 times.
✓ Branch 7 taken 8608 times.
14442 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15590
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5719 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5719 times.
✓ Branch 4 taken 172 times.
✓ Branch 5 taken 5547 times.
5719 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
15591
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5547 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5547 times.
5547 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15592 {
15593
4/8
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 115 times.
115 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
15594 115 sprite::move((zfix)-1,(zfix)0);
15595 115 }
15596
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8608 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8608 times.
✓ Branch 4 taken 5604 times.
✓ Branch 5 taken 3004 times.
✓ Branch 6 taken 123 times.
✓ Branch 7 taken 8485 times.
11612 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15597
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3004 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3004 times.
✓ Branch 4 taken 2881 times.
✓ Branch 5 taken 123 times.
3004 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
15598
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 123 times.
123 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15599 {
15600
5/8
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 106 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 123 times.
123 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
15601 123 sprite::move((zfix)1,(zfix)0);
15602 123 }
15603 else //if(shiftdir==-1)
15604 {
15605 8485 pushing=push+1;
15606
15607
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 8444 times.
8485 if(action!=swimming)
15608 {
15609 8444 }
15610 }
15611
15612 8723 z3step=2;
15613 8723 }
15614 else
15615 {
15616 2736 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15617
15618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2736 times.
2736 if(action!=swimming)
15619 {
15620 2736 }
15621
15622 2736 z3step=2;
15623 }
15624 11459 }
15625
15626 28497 return;
15627 }
15628 }
15629
15630
6/6
✓ Branch 0 taken 111365 times.
✓ Branch 1 taken 331034 times.
✓ Branch 2 taken 108136 times.
✓ Branch 3 taken 3229 times.
✓ Branch 4 taken 108035 times.
✓ Branch 5 taken 101 times.
442399 if(DrunkLeft()&&(holddir==-1||holddir==left))
15631 {
15632
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 111264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
111264 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15633 {
15634 }
15635 else
15636 {
15637
2/4
✓ Branch 0 taken 111264 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 111264 times.
111264 if(charging==0 && spins==0)
15638 {
15639 111264 dir=left;
15640 111264 }
15641
15642 111264 holddir=left;
15643
15644
4/4
✓ Branch 0 taken 5464 times.
✓ Branch 1 taken 105800 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 5463 times.
111264 if(DrunkUp()&&shiftdir!=down)
15645 {
15646 5463 shiftdir=up;
15647 5463 }
15648
3/4
✓ Branch 0 taken 4054 times.
✓ Branch 1 taken 101747 times.
✓ Branch 2 taken 4054 times.
✗ Branch 3 not taken.
105801 else if(DrunkDown()&&shiftdir!=up)
15649 {
15650 4054 shiftdir=down;
15651 4054 }
15652 else
15653 {
15654 101747 shiftdir=-1;
15655 }
15656
15657 //bool walkable;
15658 111264 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
15659
15660
2/2
✓ Branch 0 taken 70635 times.
✓ Branch 1 taken 40629 times.
111264 if(y.getInt()&7)
15661 40629 info = info || walkflag(x-z3step,y+16,1,left);
15662
15663 111264 execute(info);
15664
15665
2/2
✓ Branch 0 taken 13124 times.
✓ Branch 1 taken 98140 times.
111264 if(info.isUnwalkable())
15666 {
15667
2/2
✓ Branch 0 taken 12864 times.
✓ Branch 1 taken 260 times.
13124 if(z3step==2)
15668 {
15669 12864 z3step=1;
15670 12864 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
15671
15672
2/2
✓ Branch 0 taken 4993 times.
✓ Branch 1 taken 7871 times.
12864 if(y.getInt()&7)
15673 4993 info = info || walkflag(x-z3step,y+16,1,left);
15674
15675 12864 execute(info);
15676
15677
2/2
✓ Branch 0 taken 12595 times.
✓ Branch 1 taken 269 times.
12864 if(info.isUnwalkable())
15678 {
15679 12595 walkable = false;
15680 12595 }
15681 else
15682 {
15683 269 walkable=true;
15684 }
15685 12864 }
15686 else
15687 {
15688 260 walkable=false;
15689 }
15690 13124 }
15691 else
15692 {
15693 98140 walkable = true;
15694 }
15695
15696 111264 int32_t s=shiftdir;
15697
15698
6/14
✗ Branch 0 not taken.
✓ Branch 1 taken 111264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 56334 times.
✓ Branch 7 taken 54930 times.
✓ Branch 8 taken 56334 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 56334 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 56334 times.
✗ Branch 13 not taken.
111264 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15699 {
15700 56334 shiftdir=-1;
15701 56334 }
15702 else
15703 {
15704
2/2
✓ Branch 0 taken 50758 times.
✓ Branch 1 taken 4172 times.
54930 if(s==up)
15705 {
15706 4172 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
15707 4172 execute(info);
15708
15709
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 3772 times.
4172 if(info.isUnwalkable())
15710 {
15711 400 shiftdir=-1;
15712 400 }
15713
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 3462 times.
3772 else if(walkable)
15714 {
15715 3462 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,up);
15716 3462 execute(info);
15717
15718
2/2
✓ Branch 0 taken 3458 times.
✓ Branch 1 taken 4 times.
3462 if(info.isUnwalkable())
15719 {
15720 4 shiftdir=-1;
15721 4 }
15722 3462 }
15723 4172 }
15724
2/2
✓ Branch 0 taken 47265 times.
✓ Branch 1 taken 3493 times.
50758 else if(s==down)
15725 {
15726 3493 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
15727 3493 execute(info);
15728
15729
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 3107 times.
3493 if(info.isUnwalkable())
15730 {
15731 386 shiftdir=-1;
15732 386 }
15733
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 2826 times.
3107 else if(walkable)
15734 {
15735 2826 info = walkflag(x-1,y+16,1,down);
15736 2826 execute(info);
15737
15738
2/2
✓ Branch 0 taken 2823 times.
✓ Branch 1 taken 3 times.
2826 if(info.isUnwalkable())
15739 {
15740 3 shiftdir=-1;
15741 3 }
15742 2826 }
15743 3493 }
15744 }
15745
15746 111264 moveOld2(left);
15747 111264 shiftdir=s;
15748
15749
2/2
✓ Branch 0 taken 98409 times.
✓ Branch 1 taken 12855 times.
111264 if(!walkable)
15750 {
15751
2/2
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 11923 times.
12855 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15752 {
15753 11923 int32_t v1=bigHitbox?0:8;
15754 11923 int32_t v2=bigHitbox?8:12;
15755
15756
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 11923 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11923 times.
✓ Branch 4 taken 10609 times.
✓ Branch 5 taken 1314 times.
✓ Branch 6 taken 621 times.
✓ Branch 7 taken 11302 times.
13237 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
15757
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1314 times.
✓ Branch 2 taken 1314 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 693 times.
✓ Branch 5 taken 621 times.
1314 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
15758
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 621 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 621 times.
621 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
15759 {
15760
5/8
✓ Branch 0 taken 540 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 540 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 540 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 621 times.
621 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
15761 621 sprite::move((zfix)0,(zfix)-1);
15762 621 }
15763
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 11302 times.
✓ Branch 2 taken 11302 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 693 times.
✓ Branch 5 taken 10609 times.
✓ Branch 6 taken 224 times.
✓ Branch 7 taken 11078 times.
21911 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
15764
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10609 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10609 times.
✓ Branch 4 taken 10385 times.
✓ Branch 5 taken 224 times.
10609 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
15765
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 224 times.
224 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
15766 {
15767
6/8
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 181 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 223 times.
224 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
15768 223 sprite::move((zfix)0,(zfix)1);
15769 224 }
15770 else //if(shiftdir==-1)
15771 {
15772 11078 pushing=push+1;
15773
15774
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 11030 times.
11078 if(action!=swimming)
15775 {
15776 11030 }
15777 }
15778
15779 11923 z3step=2;
15780 11923 }
15781 else
15782 {
15783 932 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15784
15785
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 923 times.
932 if(action!=swimming)
15786 {
15787 923 }
15788
15789 932 z3step=2;
15790 }
15791 12855 }
15792
15793 111264 return;
15794 }
15795 }
15796
15797
5/6
✓ Branch 0 taken 134155 times.
✓ Branch 1 taken 196980 times.
✓ Branch 2 taken 130485 times.
✓ Branch 3 taken 3670 times.
✓ Branch 4 taken 130485 times.
✗ Branch 5 not taken.
331135 if(DrunkRight()&&(holddir==-1||holddir==right))
15798 {
15799
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 134155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
134155 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15800 {
15801 }
15802 else
15803 {
15804
2/4
✓ Branch 0 taken 134155 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 134155 times.
134155 if(charging==0 && spins==0)
15805 {
15806 134155 dir=right;
15807 134155 }
15808
15809 134155 holddir=right;
15810
15811
4/4
✓ Branch 0 taken 6952 times.
✓ Branch 1 taken 127203 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 6951 times.
134155 if(DrunkUp()&&shiftdir!=down)
15812 {
15813 6951 shiftdir=up;
15814 6951 }
15815
3/4
✓ Branch 0 taken 4918 times.
✓ Branch 1 taken 122286 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4918 times.
127204 else if(DrunkDown()&&shiftdir!=up)
15816 {
15817 4918 shiftdir=down;
15818 4918 }
15819 else
15820 {
15821 122286 shiftdir=-1;
15822 }
15823
15824 //bool walkable;
15825 134155 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
15826
15827
2/2
✓ Branch 0 taken 85264 times.
✓ Branch 1 taken 48891 times.
134155 if(y.getInt()&7)
15828 48891 info = info || walkflag(x+15+z3step,y+16,1,right);
15829
15830 134155 execute(info);
15831
15832
2/2
✓ Branch 0 taken 14498 times.
✓ Branch 1 taken 119657 times.
134155 if(info.isUnwalkable())
15833 {
15834
2/2
✓ Branch 0 taken 14220 times.
✓ Branch 1 taken 278 times.
14498 if(z3step==2)
15835 {
15836 14220 z3step=1;
15837 14220 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
15838
15839
2/2
✓ Branch 0 taken 6842 times.
✓ Branch 1 taken 7378 times.
14220 if(y.getInt()&7)
15840 6842 info = info || walkflag(x+15+z3step,y+16,1,right);
15841
15842 14220 execute(info);
15843
15844
2/2
✓ Branch 0 taken 13818 times.
✓ Branch 1 taken 402 times.
14220 if(info.isUnwalkable())
15845 {
15846 13818 walkable = false;
15847 13818 }
15848 else
15849 {
15850 402 walkable=true;
15851 }
15852 14220 }
15853 else
15854 {
15855 278 walkable=false;
15856 }
15857 14498 }
15858 else
15859 {
15860 119657 walkable = true;
15861 }
15862
15863 134155 int32_t s=shiftdir;
15864
15865
6/14
✗ Branch 0 not taken.
✓ Branch 1 taken 134155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 65926 times.
✓ Branch 7 taken 68229 times.
✓ Branch 8 taken 65926 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 65926 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 65926 times.
✗ Branch 13 not taken.
134155 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15866 {
15867 65926 shiftdir=-1;
15868 65926 }
15869 else
15870 {
15871
2/2
✓ Branch 0 taken 63040 times.
✓ Branch 1 taken 5189 times.
68229 if(s==up)
15872 {
15873 5189 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
15874 5189 execute(info);
15875
15876
2/2
✓ Branch 0 taken 379 times.
✓ Branch 1 taken 4810 times.
5189 if(info.isUnwalkable())
15877 {
15878 379 shiftdir=-1;
15879 379 }
15880
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 4416 times.
4810 else if(walkable)
15881 {
15882 4416 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,up);
15883 4416 execute(info);
15884
15885
2/2
✓ Branch 0 taken 4409 times.
✓ Branch 1 taken 7 times.
4416 if(info.isUnwalkable())
15886 {
15887 7 shiftdir=-1;
15888 7 }
15889 4416 }
15890 5189 }
15891
2/2
✓ Branch 0 taken 58599 times.
✓ Branch 1 taken 4441 times.
63040 else if(s==down)
15892 {
15893 4441 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
15894 4441 execute(info);
15895
15896
2/2
✓ Branch 0 taken 614 times.
✓ Branch 1 taken 3827 times.
4441 if(info.isUnwalkable())
15897 {
15898 614 shiftdir=-1;
15899 614 }
15900
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 3377 times.
3827 else if(walkable)
15901 {
15902 3377 info = walkflag(x+16,y+16,1,down);
15903 3377 execute(info);
15904
15905
2/2
✓ Branch 0 taken 3363 times.
✓ Branch 1 taken 14 times.
3377 if(info.isUnwalkable())
15906 {
15907 14 shiftdir=-1;
15908 14 }
15909 3377 }
15910 4441 }
15911 }
15912
15913 134155 moveOld2(right);
15914 134155 shiftdir=s;
15915
15916
2/2
✓ Branch 0 taken 120059 times.
✓ Branch 1 taken 14096 times.
134155 if(!walkable)
15917 {
15918
2/2
✓ Branch 0 taken 1415 times.
✓ Branch 1 taken 12681 times.
14096 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15919 {
15920 12681 int32_t v1=bigHitbox?0:8;
15921 12681 int32_t v2=bigHitbox?8:12;
15922
15923 38043 info = !walkflag(x+16,y+v1,1,right)&&
15924 25362 !walkflag(x+16,y+v2,1,right)&&
15925 12681 walkflag(x+16,y+15,1,right);
15926
15927 //do NOT execute these
15928
2/2
✓ Branch 0 taken 930 times.
✓ Branch 1 taken 11751 times.
12681 if(info.isUnwalkable())
15929 {
15930
6/8
✓ Branch 0 taken 905 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 905 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 905 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 929 times.
930 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
15931 929 sprite::move((zfix)0,(zfix)-1);
15932 930 }
15933 else
15934 {
15935 35253 info = walkflag(x+16,y+v1, 1,right)&&
15936 23502 !walkflag(x+16,y+v2-1,1,right)&&
15937 11751 !walkflag(x+16,y+15, 1,right);
15938
15939
2/2
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 11437 times.
11751 if(info.isUnwalkable())
15940 {
15941
5/8
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 299 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 299 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 314 times.
314 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
15942 314 sprite::move((zfix)0,(zfix)1);
15943 314 }
15944 else //if(shiftdir==-1)
15945 {
15946 11437 pushing=push+1;
15947 11437 z3step=2;
15948
15949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11437 times.
11437 if(action!=swimming)
15950 {
15951 11437 }
15952 }
15953 }
15954
15955 12681 z3step=2;
15956 12681 }
15957 else
15958 {
15959 1415 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15960
15961
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1409 times.
1415 if(action!=swimming)
15962 {
15963 1409 }
15964
15965 1415 z3step=2;
15966 }
15967 14096 }
15968
15969 134155 return;
15970 }
15971 }
15972 }
15973
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 242711 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
242711 if(shield_forcedir > -1 && action != rafting)
15974 dir = shield_forcedir;
15975 242711 int32_t wtry = iswaterex(MAPCOMBO(x,y+15), currmap, currscr, -1, x,y+15, true, false);
15976 242711 int32_t wtry8 = iswaterex(MAPCOMBO(x+15,y+15), currmap, currscr, -1, x+15,y+15, true, false);
15977 242711 int32_t wtrx = iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)), currmap, currscr, -1, x,y+(bigHitbox?0:8), true, false);
15978 242711 int32_t wtrx8 = iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)), currmap, currscr, -1, x+15,y+(bigHitbox?0:8), true, false);
15979 242711 int32_t wtrc = iswaterex(MAPCOMBO(x+8,y+(bigHitbox?8:12)), currmap, currscr, -1, x+8,y+(bigHitbox?8:12), true, false);
15980
15981
8/12
✓ Branch 0 taken 70324 times.
✓ Branch 1 taken 172387 times.
✓ Branch 2 taken 70324 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 70324 times.
✓ Branch 6 taken 70324 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 67541 times.
✓ Branch 9 taken 2783 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 67541 times.
242711 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))&&!(ladderx+laddery)&&z==0&&fakez==0)
15982 {
15983
8/12
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 67340 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 33 times.
✓ Branch 4 taken 152 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 152 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 152 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
67541 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
15984 {
15985 //action=swimming;
15986
3/12
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
152 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
15987 {
15988 hopclk = 0xFF;
15989 }
15990 152 }
15991 67541 }
15992
15993 242711 return;
15994 } //endif (LTTPWALK)
15995 2331044 temp_step = hero_newstep;
15996 2331044 temp_x = x;
15997 2331044 temp_y = y;
15998
15999
7/8
✓ Branch 0 taken 1488166 times.
✓ Branch 1 taken 842878 times.
✓ Branch 2 taken 1456775 times.
✓ Branch 3 taken 31391 times.
✓ Branch 4 taken 43770 times.
✓ Branch 5 taken 1444396 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 43770 times.
2331044 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
16000 {
16001
2/4
✓ Branch 0 taken 43770 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 43770 times.
43770 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
16002 goto LEFTRIGHT_NEWMOVE;
16003 43770 else goto LEFTRIGHT_OLDMOVE;
16004 }
16005
16006 // make it easier to get in left & right doors
16007
16008 //ignore ladder for this part. sigh sigh sigh -DD
16009 2287274 oldladderx = ladderx;
16010 2287274 oldladdery = laddery;
16011
2/4
✓ Branch 0 taken 2287274 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2287274 times.
2287274 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
16012 {
16013 if(isdungeon() && DrunkLeft() && (temp_x==32 && temp_y==80))
16014 {
16015 do
16016 {
16017 info = walkflag(temp_x,temp_y+(bigHitbox?0:8),1,left) ||
16018 walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left);
16019
16020 if(info.isUnwalkable())
16021 {
16022 if(temp_x != int32_t(temp_x))
16023 {
16024 temp_x = floor((double)temp_x);
16025 }
16026 else if(temp_step > 1)
16027 {
16028 if(temp_step != int32_t(temp_step)) //floor
16029 temp_step = floor((double)temp_step);
16030 else --temp_step;
16031 }
16032 else
16033 break;
16034 }
16035 }
16036 while(info.isUnwalkable());
16037
16038 if(!info.isUnwalkable())
16039 {
16040 x = temp_x;
16041 y = temp_y;
16042 hero_newstep = temp_step;
16043 //ONLY process the side-effects of the above walkflag if Hero will actually move
16044 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
16045 execute(info);
16046 moveOld2(left);
16047 return;
16048 }
16049 temp_x = x;
16050 temp_y = y;
16051 temp_step = hero_newstep;
16052 }
16053
16054 if(isdungeon() && DrunkRight() && temp_x==208 && temp_y==80)
16055 {
16056 do
16057 {
16058 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
16059 walkflag(temp_x+15+temp_step,temp_y+8,1,right);
16060
16061 if(info.isUnwalkable())
16062 {
16063 if(temp_x != int32_t(temp_x))
16064 {
16065 temp_x = floor((double)temp_x);
16066 }
16067 else if(temp_step > 1)
16068 {
16069 if(temp_step != int32_t(temp_step)) //floor
16070 temp_step = floor((double)temp_step);
16071 else --temp_step;
16072 }
16073 else
16074 break;
16075 }
16076 }
16077 while(info.isUnwalkable());
16078
16079 if(!info.isUnwalkable())
16080 {
16081 x = temp_x;
16082 y = temp_y;
16083 hero_newstep = temp_step;
16084 execute(info);
16085 moveOld2(right);
16086 return;
16087 }
16088 temp_x = x;
16089 temp_y = y;
16090 temp_step = hero_newstep;
16091 }
16092
16093 ladderx = oldladderx;
16094 laddery = oldladdery;
16095
16096 if(DrunkUp())
16097 {
16098 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16099 {
16100 if(dir!=up && dir!=down)
16101 {
16102 if(xoff>2&&xoff<6)
16103 {
16104 moveOld2(dir);
16105 }
16106 else if(xoff>=6)
16107 {
16108 moveOld2(right);
16109 }
16110 else if(xoff>=1)
16111 {
16112 moveOld2(left);
16113 }
16114 }
16115 else
16116 {
16117 if(xoff>=4)
16118 {
16119 moveOld2(right);
16120 }
16121 else if(xoff<4)
16122 {
16123 moveOld2(left);
16124 }
16125 }
16126 }
16127 else
16128 {
16129 do
16130 {
16131 if(action==swimming || IsSideSwim() || action == swimhit)
16132 {
16133 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
16134
16135 if(_walkflag(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, 1,SWITCHBLOCK_STATE) &&
16136 !(iswaterex(MAPCOMBO(temp_x, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x, temp_y+(bigHitbox?0:8)-temp_step, true, false) &&
16137 iswaterex(MAPCOMBO(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, true, false)))
16138 info.setUnwalkable(true);
16139 }
16140 else
16141 {
16142 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
16143 if(x.getInt() & 7)
16144 info = info || walkflag(temp_x+16,temp_y+(bigHitbox?0:8)-temp_step,1,up);
16145 else
16146 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
16147 }
16148
16149 if(info.isUnwalkable())
16150 {
16151 if(temp_y != int32_t(temp_y))
16152 {
16153 temp_y = floor((double)temp_y);
16154 }
16155 else if(temp_step > 1)
16156 {
16157 if(temp_step != int32_t(temp_step)) //floor
16158 temp_step = floor((double)temp_step);
16159 else --temp_step;
16160 }
16161 else
16162 break;
16163 }
16164 }
16165 while(info.isUnwalkable());
16166
16167 execute(info);
16168
16169 if(!info.isUnwalkable())
16170 {
16171 x = temp_x;
16172 y = temp_y;
16173 hero_newstep = temp_step;
16174 moveOld2(up);
16175 return;
16176 }
16177
16178 if(!DrunkLeft() && !DrunkRight())
16179 {
16180 if(NO_GRIDLOCK)
16181 {
16182 x = x.getInt();
16183 y = y.getInt();
16184 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16185 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16186 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16187 {
16188 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
16189 sprite::move((zfix)-1,(zfix)0);
16190 }
16191 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16192 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16193 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16194 {
16195 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
16196 sprite::move((zfix)1,(zfix)0);
16197 }
16198 else
16199 {
16200 pushing=push+1;
16201 }
16202 }
16203 else pushing=push+1;
16204
16205 if(charging==0 && spins==0)
16206 {
16207 dir=up;
16208 }
16209
16210 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16211 {
16212 herostep();
16213 }
16214
16215 return;
16216 }
16217 else
16218 {
16219 goto LEFTRIGHT_NEWMOVE;
16220 }
16221 }
16222
16223 return;
16224 }
16225
16226 if(DrunkDown())
16227 {
16228 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16229 {
16230 if(dir!=up && dir!=down)
16231 {
16232 if(xoff>2&&xoff<6)
16233 {
16234 moveOld2(dir);
16235 }
16236 else if(xoff>=6)
16237 {
16238 moveOld2(right);
16239 }
16240 else if(xoff>=1)
16241 {
16242 moveOld2(left);
16243 }
16244 }
16245 else
16246 {
16247 if(xoff>=4)
16248 {
16249 moveOld2(right);
16250 }
16251 else if(xoff<4)
16252 {
16253 moveOld2(left);
16254 }
16255 }
16256 }
16257 else
16258 {
16259 do
16260 {
16261 if(action==swimming || IsSideSwim() || action == swimhit)
16262 {
16263 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
16264
16265 if(_walkflag(temp_x+15, temp_y+15+temp_step, 1,SWITCHBLOCK_STATE) &&
16266 !(iswaterex(MAPCOMBO(temp_x, temp_y+15+temp_step), currmap, currscr, -1, temp_x, temp_y+15+temp_step, true, false) &&
16267 iswaterex(MAPCOMBO(temp_x+15, temp_y+15+temp_step), currmap, currscr, -1, temp_x+15, temp_y+15+temp_step, true, false)))
16268 info.setUnwalkable(true);
16269 }
16270 else
16271 {
16272 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
16273 if(x.getInt() & 7)
16274 info = info || walkflag(temp_x+16,temp_y+15+temp_step,1,down);
16275 else
16276 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
16277 }
16278
16279 if(info.isUnwalkable())
16280 {
16281 if(temp_y != int32_t(temp_y))
16282 {
16283 temp_y = floor((double)temp_y);
16284 }
16285 else if(temp_step > 1)
16286 {
16287 if(temp_step != int32_t(temp_step)) //floor
16288 temp_step = floor((double)temp_step);
16289 else --temp_step;
16290 }
16291 else
16292 break;
16293 }
16294 }
16295 while(info.isUnwalkable());
16296
16297 execute(info);
16298
16299 if(!info.isUnwalkable())
16300 {
16301 x = temp_x;
16302 y = temp_y;
16303 hero_newstep = temp_step;
16304 moveOld2(down);
16305 return;
16306 }
16307
16308 if(!DrunkLeft() && !DrunkRight())
16309 {
16310 if(NO_GRIDLOCK)
16311 {
16312 x = x.getInt();
16313 y = y.getInt();
16314 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16315 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
16316 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16317 {
16318 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
16319 sprite::move((zfix)-1,(zfix)0);
16320 }
16321 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16322 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
16323 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16324 {
16325 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
16326 sprite::move((zfix)1,(zfix)0);
16327 }
16328 else
16329 {
16330 pushing=push+1;
16331 }
16332 }
16333 else pushing=push+1;
16334
16335 if(charging==0 && spins==0)
16336 {
16337 dir=down;
16338 }
16339
16340 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16341 {
16342 herostep();
16343 }
16344
16345 return;
16346 }
16347 else goto LEFTRIGHT_NEWMOVE;
16348 }
16349
16350 return;
16351 }
16352
16353 LEFTRIGHT_NEWMOVE:
16354 temp_x = x;
16355 temp_y = y;
16356 temp_step = hero_newstep;
16357 if(isdungeon() && (temp_y<=26 || temp_y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
16358 {
16359 return;
16360 }
16361
16362 if(DrunkLeft())
16363 {
16364 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16365 {
16366 if(dir!=left && dir!=right)
16367 {
16368 if(yoff>2&&yoff<6)
16369 {
16370 moveOld2(dir);
16371 }
16372 else if(yoff>=6)
16373 {
16374 moveOld2(down);
16375 }
16376 else if(yoff>=1)
16377 {
16378 moveOld2(up);
16379 }
16380 }
16381 else
16382 {
16383 if(yoff>=4)
16384 {
16385 moveOld2(down);
16386 }
16387 else if(yoff<4)
16388 {
16389 moveOld2(up);
16390 }
16391 }
16392 }
16393 else
16394 {
16395 do
16396 {
16397 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) ||
16398 walkflag(temp_x-temp_step,temp_y+(isSideViewHero() ?0:8), 1,left);
16399
16400 if(y.getInt() & 7)
16401 info = info || walkflag(temp_x-temp_step,temp_y+16,1,left);
16402
16403 if(info.isUnwalkable())
16404 {
16405 if(temp_x != int32_t(temp_x))
16406 {
16407 temp_x = floor((double)temp_x);
16408 }
16409 else if(temp_step > 1)
16410 {
16411 if(temp_step != int32_t(temp_step)) //floor
16412 temp_step = floor((double)temp_step);
16413 else --temp_step;
16414 }
16415 else
16416 break;
16417 }
16418 }
16419 while(info.isUnwalkable());
16420
16421 execute(info);
16422
16423 if(!info.isUnwalkable())
16424 {
16425 x = temp_x;
16426 y = temp_y;
16427 hero_newstep = temp_step;
16428 moveOld2(left);
16429 return;
16430 }
16431
16432 if(!DrunkUp() && !DrunkDown())
16433 {
16434 if(NO_GRIDLOCK)
16435 {
16436 x = x.getInt();
16437 y = y.getInt();
16438 int32_t v1=bigHitbox?0:8;
16439 int32_t v2=bigHitbox?8:12;
16440
16441 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16442 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16443 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16444 {
16445 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
16446 sprite::move((zfix)0,(zfix)-1);
16447 }
16448 else if(_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16449 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
16450 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
16451 {
16452 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
16453 sprite::move((zfix)0,(zfix)1);
16454 }
16455 else
16456 {
16457 pushing=push+1;
16458 }
16459 }
16460 else pushing=push+1;
16461
16462 if(charging==0 && spins==0)
16463 {
16464 dir=left;
16465 }
16466
16467 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16468 {
16469 herostep();
16470 }
16471
16472 return;
16473 }
16474 }
16475
16476 return;
16477 }
16478
16479 if(DrunkRight())
16480 {
16481 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16482 {
16483 if(dir!=left && dir!=right)
16484 {
16485 if(yoff>2&&yoff<6)
16486 {
16487 moveOld2(dir);
16488 }
16489 else if(yoff>=6)
16490 {
16491 moveOld2(down);
16492 }
16493 else if(yoff>=1)
16494 {
16495 moveOld2(up);
16496 }
16497 }
16498 else
16499 {
16500 if(yoff>=4)
16501 {
16502 moveOld2(down);
16503 }
16504 else if(yoff<4)
16505 {
16506 moveOld2(up);
16507 }
16508 }
16509 }
16510 else
16511 {
16512 do
16513 {
16514 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
16515 walkflag(temp_x+15+temp_step,temp_y+(isSideViewHero() ?0:8),1,right);
16516
16517 if(y.getInt() & 7)
16518 info = info || walkflag(temp_x+15+temp_step,y+16,1,right);
16519
16520 if(info.isUnwalkable())
16521 {
16522 if(temp_x != int32_t(temp_x))
16523 {
16524 temp_x = floor((double)temp_x);
16525 }
16526 else if(temp_step > 1)
16527 {
16528 if(temp_step != int32_t(temp_step)) //floor
16529 temp_step = floor((double)temp_step);
16530 else --temp_step;
16531 }
16532 else
16533 break;
16534 }
16535 }
16536 while(info.isUnwalkable());
16537
16538 execute(info);
16539
16540 if(!info.isUnwalkable())
16541 {
16542 x = temp_x;
16543 y = temp_y;
16544 hero_newstep = temp_step;
16545 moveOld2(right);
16546 return;
16547 }
16548
16549 if(!DrunkUp() && !DrunkDown())
16550 {
16551 if(NO_GRIDLOCK)
16552 {
16553 x = x.getInt();
16554 y = y.getInt();
16555 int32_t v1=bigHitbox?0:8;
16556 int32_t v2=bigHitbox?8:12;
16557
16558 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16559 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
16560 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16561 {
16562 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
16563 sprite::move((zfix)0,(zfix)-1);
16564 }
16565 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16566 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
16567 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16568 {
16569 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
16570 sprite::move((zfix)0,(zfix)1);
16571 }
16572 else
16573 {
16574 pushing=push+1;
16575 }
16576 }
16577 else pushing=push+1;
16578
16579 if(charging==0 && spins==0)
16580 {
16581 dir=right;
16582 }
16583
16584 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16585 {
16586 herostep();
16587 }
16588
16589 return;
16590 }
16591 }
16592 }
16593 }
16594 else
16595 {
16596 4574548 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
16597 2287274 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
16598
16599
10/10
✓ Branch 0 taken 1444396 times.
✓ Branch 1 taken 842878 times.
✓ Branch 2 taken 178263 times.
✓ Branch 3 taken 1266133 times.
✓ Branch 4 taken 102609 times.
✓ Branch 5 taken 75654 times.
✓ Branch 6 taken 927 times.
✓ Branch 7 taken 101682 times.
✓ Branch 8 taken 842 times.
✓ Branch 9 taken 85 times.
2287274 if(isdungeon() && DrunkLeft() && !info.isUnwalkable() && (x==32 && y==80))
16600 {
16601 //ONLY process the side-effects of the above walkflag if Hero will actually move
16602 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
16603 842 execute(info);
16604 842 moveOld2(left);
16605 842 return;
16606 }
16607
16608 4572864 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) ||
16609 2286432 walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
16610
16611
10/10
✓ Branch 0 taken 1443554 times.
✓ Branch 1 taken 842878 times.
✓ Branch 2 taken 198489 times.
✓ Branch 3 taken 1245065 times.
✓ Branch 4 taken 111526 times.
✓ Branch 5 taken 86963 times.
✓ Branch 6 taken 1146 times.
✓ Branch 7 taken 110380 times.
✓ Branch 8 taken 88 times.
✓ Branch 9 taken 1058 times.
2286432 if(isdungeon() && DrunkRight() && !info.isUnwalkable() && x==208 && y==80)
16612 {
16613 1058 execute(info);
16614 1058 moveOld2(right);
16615 1058 return;
16616 }
16617
16618 2285374 ladderx = oldladderx;
16619 2285374 laddery = oldladdery;
16620
16621
2/2
✓ Branch 0 taken 246116 times.
✓ Branch 1 taken 2039258 times.
2285374 if(DrunkUp())
16622 {
16623
11/14
✓ Branch 0 taken 6732 times.
✓ Branch 1 taken 239384 times.
✓ Branch 2 taken 6279 times.
✓ Branch 3 taken 453 times.
✓ Branch 4 taken 5253 times.
✓ Branch 5 taken 1026 times.
✓ Branch 6 taken 5253 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5253 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5253 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 5250 times.
246116 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16624 {
16625
3/4
✓ Branch 0 taken 5217 times.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5217 times.
5250 if(dir!=up && dir!=down)
16626 {
16627
4/4
✓ Branch 0 taken 3611 times.
✓ Branch 1 taken 1606 times.
✓ Branch 2 taken 1553 times.
✓ Branch 3 taken 2058 times.
5217 if(xoff>2&&xoff<6)
16628 {
16629 2058 moveOld2(dir);
16630 2058 }
16631
2/2
✓ Branch 0 taken 1553 times.
✓ Branch 1 taken 1606 times.
3159 else if(xoff>=6)
16632 {
16633 1553 moveOld2(right);
16634 1553 }
16635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1606 times.
1606 else if(xoff>=1)
16636 {
16637 1606 moveOld2(left);
16638 1606 }
16639 5217 }
16640 else
16641 {
16642
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 23 times.
33 if(xoff>=4)
16643 {
16644 10 moveOld2(right);
16645 10 }
16646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 else if(xoff<4)
16647 {
16648 23 moveOld2(left);
16649 23 }
16650 }
16651 5250 }
16652 else
16653 {
16654
4/6
✓ Branch 0 taken 229480 times.
✓ Branch 1 taken 11386 times.
✓ Branch 2 taken 229480 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 229480 times.
240866 if(action==swimming || IsSideSwim() || action == swimhit)
16655 {
16656 11386 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
16657
16658
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 11386 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11386 times.
✓ Branch 4 taken 944 times.
✓ Branch 5 taken 10442 times.
✓ Branch 6 taken 8870 times.
✓ Branch 7 taken 2516 times.
21828 if(_walkflag(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
16659
2/2
✓ Branch 0 taken 2488 times.
✓ Branch 1 taken 7954 times.
18396 !(iswaterex(MAPCOMBO(x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])) &&
16660 7954 iswaterex(MAPCOMBO(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]))))
16661 2516 info.setUnwalkable(true);
16662 11386 }
16663 else
16664 {
16665 229480 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
16666
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 229023 times.
229480 if(x.getInt() & 7)
16667 457 info = info || walkflag(x+16,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),1,up);
16668 else
16669 229023 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
16670 }
16671
16672 240866 execute(info);
16673
16674
2/2
✓ Branch 0 taken 109225 times.
✓ Branch 1 taken 131641 times.
240866 if(!info.isUnwalkable())
16675 {
16676 131641 moveOld2(up);
16677 131641 return;
16678 }
16679
16680
4/4
✓ Branch 0 taken 98303 times.
✓ Branch 1 taken 10922 times.
✓ Branch 2 taken 11154 times.
✓ Branch 3 taken 87149 times.
109225 if(!DrunkLeft() && !DrunkRight())
16681 {
16682
2/4
✓ Branch 0 taken 87149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87149 times.
✗ Branch 3 not taken.
87149 if(NO_GRIDLOCK)
16683 {
16684 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16685 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16686 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16687 {
16688 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
16689 sprite::move((zfix)-1,(zfix)0);
16690 }
16691 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16692 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16693 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16694 {
16695 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
16696 sprite::move((zfix)1,(zfix)0);
16697 }
16698 else
16699 {
16700 pushing=push+1;
16701 }
16702 }
16703 87149 else pushing=push+1;
16704
16705
4/4
✓ Branch 0 taken 86966 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 86870 times.
✓ Branch 3 taken 96 times.
87149 if(charging==0 && spins==0)
16706 {
16707 86870 dir=up;
16708 86870 }
16709
16710
5/8
✓ Branch 0 taken 85249 times.
✓ Branch 1 taken 1900 times.
✓ Branch 2 taken 85249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 85249 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 85249 times.
87149 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16711 {
16712 85249 herostep();
16713 85249 }
16714
16715 87149 return;
16716 }
16717 else
16718 {
16719 22076 goto LEFTRIGHT_OLDMOVE;
16720 }
16721 }
16722
16723 5250 return;
16724 }
16725
16726
2/2
✓ Branch 0 taken 217458 times.
✓ Branch 1 taken 1821800 times.
2039258 if(DrunkDown())
16727 {
16728
11/14
✓ Branch 0 taken 6486 times.
✓ Branch 1 taken 210972 times.
✓ Branch 2 taken 6213 times.
✓ Branch 3 taken 273 times.
✓ Branch 4 taken 4178 times.
✓ Branch 5 taken 2035 times.
✓ Branch 6 taken 4178 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4178 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4178 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 4177 times.
217458 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16729 {
16730
3/4
✓ Branch 0 taken 4177 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4176 times.
4177 if(dir!=up && dir!=down)
16731 {
16732
4/4
✓ Branch 0 taken 2932 times.
✓ Branch 1 taken 1244 times.
✓ Branch 2 taken 1236 times.
✓ Branch 3 taken 1696 times.
4176 if(xoff>2&&xoff<6)
16733 {
16734 1696 moveOld2(dir);
16735 1696 }
16736
2/2
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 1244 times.
2480 else if(xoff>=6)
16737 {
16738 1236 moveOld2(right);
16739 1236 }
16740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1244 times.
1244 else if(xoff>=1)
16741 {
16742 1244 moveOld2(left);
16743 1244 }
16744 4176 }
16745 else
16746 {
16747
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(xoff>=4)
16748 {
16749 1 moveOld2(right);
16750 1 }
16751 else if(xoff<4)
16752 {
16753 moveOld2(left);
16754 }
16755 }
16756 4177 }
16757 else
16758 {
16759
4/6
✓ Branch 0 taken 200717 times.
✓ Branch 1 taken 12564 times.
✓ Branch 2 taken 200717 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 200717 times.
213281 if(action==swimming || IsSideSwim() || action == swimhit)
16760 {
16761 12564 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
16762
16763
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 12564 times.
✓ Branch 2 taken 12564 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 893 times.
✓ Branch 5 taken 11671 times.
✓ Branch 6 taken 8139 times.
✓ Branch 7 taken 4425 times.
24235 if(_walkflag(x+15, y+15+int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
16764
2/2
✓ Branch 0 taken 4353 times.
✓ Branch 1 taken 7318 times.
18989 !(iswaterex(MAPCOMBO(x, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+15+int32_t(lsteps[y.getInt()&7])) &&
16765 7318 iswaterex(MAPCOMBO(x+15, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+15+int32_t(lsteps[y.getInt()&7]))))
16766 4425 info.setUnwalkable(true);
16767 12564 }
16768 else
16769 {
16770 200717 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
16771
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 200442 times.
200717 if(x.getInt() & 7)
16772 275 info = (info || walkflag(x+16,y+15+int32_t(lsteps[y.getInt()&7]),1,down));
16773 else
16774 200442 info = (info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7])));
16775 }
16776
16777 213281 execute(info);
16778
16779
2/2
✓ Branch 0 taken 103740 times.
✓ Branch 1 taken 109541 times.
213281 if(!info.isUnwalkable())
16780 {
16781 109541 moveOld2(down);
16782 109541 return;
16783 }
16784
16785
4/4
✓ Branch 0 taken 91973 times.
✓ Branch 1 taken 11767 times.
✓ Branch 2 taken 11308 times.
✓ Branch 3 taken 80665 times.
103740 if(!DrunkLeft() && !DrunkRight())
16786 {
16787
2/4
✓ Branch 0 taken 80665 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80665 times.
✗ Branch 3 not taken.
80665 if(NO_GRIDLOCK)
16788 {
16789 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16790 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
16791 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16792 {
16793 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
16794 sprite::move((zfix)-1,(zfix)0);
16795 }
16796 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16797 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
16798 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16799 {
16800 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
16801 sprite::move((zfix)1,(zfix)0);
16802 }
16803 else
16804 {
16805 pushing=push+1;
16806 }
16807 }
16808 80665 else pushing=push+1;
16809
16810
2/4
✓ Branch 0 taken 80665 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80665 times.
✗ Branch 3 not taken.
80665 if(charging==0 && spins==0)
16811 {
16812 80665 dir=down;
16813 80665 }
16814
16815
5/8
✓ Branch 0 taken 78697 times.
✓ Branch 1 taken 1968 times.
✓ Branch 2 taken 78697 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 78697 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 78697 times.
80665 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16816 {
16817 78697 herostep();
16818 78697 }
16819
16820 80665 return;
16821 }
16822 23075 else goto LEFTRIGHT_OLDMOVE;
16823 }
16824
16825 4177 return;
16826 }
16827
16828 LEFTRIGHT_OLDMOVE:
16829
16830
7/8
✓ Branch 0 taken 1211415 times.
✓ Branch 1 taken 699306 times.
✓ Branch 2 taken 1176030 times.
✓ Branch 3 taken 35385 times.
✓ Branch 4 taken 44836 times.
✓ Branch 5 taken 1166579 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 44836 times.
1910721 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
16831 {
16832 44836 return;
16833 }
16834
16835
2/2
✓ Branch 0 taken 278475 times.
✓ Branch 1 taken 1587410 times.
1865885 if(DrunkLeft())
16836 {
16837
11/14
✓ Branch 0 taken 4749 times.
✓ Branch 1 taken 273726 times.
✓ Branch 2 taken 4715 times.
✓ Branch 3 taken 34 times.
✓ Branch 4 taken 4444 times.
✓ Branch 5 taken 271 times.
✓ Branch 6 taken 4444 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4444 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4444 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 4442 times.
278475 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16838 {
16839
3/4
✓ Branch 0 taken 4437 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4437 times.
4442 if(dir!=left && dir!=right)
16840 {
16841
4/4
✓ Branch 0 taken 3161 times.
✓ Branch 1 taken 1276 times.
✓ Branch 2 taken 1345 times.
✓ Branch 3 taken 1816 times.
4437 if(yoff>2&&yoff<6)
16842 {
16843 1816 moveOld2(dir);
16844 1816 }
16845
2/2
✓ Branch 0 taken 1345 times.
✓ Branch 1 taken 1276 times.
2621 else if(yoff>=6)
16846 {
16847 1345 moveOld2(down);
16848 1345 }
16849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1276 times.
1276 else if(yoff>=1)
16850 {
16851 1276 moveOld2(up);
16852 1276 }
16853 4437 }
16854 else
16855 {
16856
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(yoff>=4)
16857 {
16858 5 moveOld2(down);
16859 5 }
16860 else if(yoff<4)
16861 {
16862 moveOld2(up);
16863 }
16864 }
16865 4442 }
16866 else
16867 {
16868 548066 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
16869 274033 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero() ?0:8), 1,left);
16870
16871 274033 execute(info);
16872
16873
2/2
✓ Branch 0 taken 110607 times.
✓ Branch 1 taken 163426 times.
274033 if(!info.isUnwalkable())
16874 {
16875 163426 moveOld2(left);
16876 163426 return;
16877 }
16878
16879
4/4
✓ Branch 0 taken 105025 times.
✓ Branch 1 taken 5582 times.
✓ Branch 2 taken 6065 times.
✓ Branch 3 taken 98960 times.
110607 if(!DrunkUp() && !DrunkDown())
16880 {
16881
2/4
✓ Branch 0 taken 98960 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98960 times.
98960 if(NO_GRIDLOCK)
16882 {
16883 int32_t v1=bigHitbox?0:8;
16884 int32_t v2=bigHitbox?8:12;
16885
16886 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16887 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16888 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16889 {
16890 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
16891 sprite::move((zfix)0,(zfix)-1);
16892 }
16893 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
16894 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
16895 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
16896 {
16897 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
16898 sprite::move((zfix)0,(zfix)1);
16899 }
16900 else
16901 {
16902 pushing=push+1;
16903 }
16904 }
16905 98960 else pushing=push+1;
16906
16907
3/4
✓ Branch 0 taken 98954 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98954 times.
98960 if(charging==0 && spins==0)
16908 {
16909 98954 dir=left;
16910 98954 }
16911
16912
5/8
✓ Branch 0 taken 95979 times.
✓ Branch 1 taken 2981 times.
✓ Branch 2 taken 95979 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 95979 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 95979 times.
98960 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16913 {
16914 95979 herostep();
16915 95979 }
16916
16917 98960 return;
16918 }
16919 }
16920
16921 16089 return;
16922 }
16923
16924
2/2
✓ Branch 0 taken 1288902 times.
✓ Branch 1 taken 298508 times.
1587410 if(DrunkRight())
16925 {
16926
10/14
✓ Branch 0 taken 4795 times.
✓ Branch 1 taken 293713 times.
✓ Branch 2 taken 4674 times.
✓ Branch 3 taken 121 times.
✓ Branch 4 taken 4569 times.
✓ Branch 5 taken 105 times.
✓ Branch 6 taken 4569 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4569 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4569 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 4569 times.
298508 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16927 {
16928
4/4
✓ Branch 0 taken 4566 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 4563 times.
4569 if(dir!=left && dir!=right)
16929 {
16930
4/4
✓ Branch 0 taken 3247 times.
✓ Branch 1 taken 1316 times.
✓ Branch 2 taken 1372 times.
✓ Branch 3 taken 1875 times.
4563 if(yoff>2&&yoff<6)
16931 {
16932 1875 moveOld2(dir);
16933 1875 }
16934
2/2
✓ Branch 0 taken 1372 times.
✓ Branch 1 taken 1316 times.
2688 else if(yoff>=6)
16935 {
16936 1372 moveOld2(down);
16937 1372 }
16938
1/2
✓ Branch 0 taken 1316 times.
✗ Branch 1 not taken.
1316 else if(yoff>=1)
16939 {
16940 1316 moveOld2(up);
16941 1316 }
16942 4563 }
16943 else
16944 {
16945
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
6 if(yoff>=4)
16946 {
16947 1 moveOld2(down);
16948 1 }
16949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 else if(yoff<4)
16950 {
16951 5 moveOld2(up);
16952 5 }
16953 }
16954 4569 }
16955 else
16956 {
16957 587878 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right)
16958 293939 || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero()?0:8),1,right);
16959
16960 293939 execute(info);
16961
16962
2/2
✓ Branch 0 taken 118084 times.
✓ Branch 1 taken 175855 times.
293939 if(!info.isUnwalkable())
16963 {
16964 175855 moveOld2(right);
16965 175855 return;
16966 }
16967
16968
4/4
✓ Branch 0 taken 113337 times.
✓ Branch 1 taken 4747 times.
✓ Branch 2 taken 5143 times.
✓ Branch 3 taken 108194 times.
118084 if(!DrunkUp() && !DrunkDown())
16969 {
16970
2/4
✓ Branch 0 taken 108194 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108194 times.
108194 if(NO_GRIDLOCK)
16971 {
16972 int32_t v1=bigHitbox?0:8;
16973 int32_t v2=bigHitbox?8:12;
16974
16975 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16976 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
16977 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16978 {
16979 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
16980 sprite::move((zfix)0,(zfix)-1);
16981 }
16982 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16983 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
16984 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16985 {
16986 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
16987 sprite::move((zfix)0,(zfix)1);
16988 }
16989 else
16990 {
16991 pushing=push+1;
16992 }
16993 }
16994 108194 else pushing=push+1;
16995
16996
2/4
✓ Branch 0 taken 108194 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108194 times.
108194 if(charging==0 && spins==0)
16997 {
16998 108194 dir=right;
16999 108194 }
17000
17001
5/8
✓ Branch 0 taken 107219 times.
✓ Branch 1 taken 975 times.
✓ Branch 2 taken 107219 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107219 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 107219 times.
108194 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17002 {
17003 107219 herostep();
17004 107219 }
17005
17006 108194 return;
17007 }
17008 }
17009 14459 }
17010 }
17011 6178792 }
17012
17013 49271 bool HeroClass::scr_walkflag(int dx,int dy,int d2,int mx,int my,bool kb)
17014 {
17015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49271 times.
49271 if(toogam) return false;
17016
17017
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49271 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
49271 if(blockpath && dy<80) //Blocked top parts of rooms
17018 return true;
17019
17020
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49271 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
49271 if(blockmoving && mblock2.hit(dx,dy,0,1,1,1))
17021 return true;
17022 //collide_object handled in scr_canmove
17023
17024
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 49271 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 49271 times.
49271 if(isdungeon() && currscr<128 && dy<32
17025 && ((x<=112||x>=128) || _walkflag(120,24,2,SWITCHBLOCK_STATE))
17026 && !get_bit(quest_rules,qr_FREEFORM))
17027 return false; //Old NES dungeon stuff
17028
17029
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49271 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49271 times.
49271 bool solid = _walkflag(dx,dy,1,SWITCHBLOCK_STATE);
17030
17031
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 49271 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
49271 if(isdungeon() && currscr<128 && !get_bit(quest_rules,qr_FREEFORM))
17032 {
17033 if(mx>=112&&mx<120&&my<40&&my>=32)
17034 solid=true;
17035
17036 if(mx>=136&&mx<144&&my<40&&my>=32)
17037 solid=true;
17038 }
17039
17040
2/4
✓ Branch 0 taken 49271 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 49271 times.
49271 if(action==swimming || IsSideSwim())
17041 {
17042 if(!solid)
17043 {
17044 bool isthissolid = false;
17045 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
17046 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
17047 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
17048 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
17049 isthissolid = true;
17050 //This checks if Hero is currently swimming in solid water (cause even if the QR "No Hopping" is enabled, he should still hop out of solid water) - Dimi
17051
17052 int ls = 22;
17053 if((get_bit(quest_rules,qr_DROWN) && isSwimming()) || (!diagonalMovement) || get_bit(quest_rules,qr_NO_HOPPING))
17054 ls = 1;
17055 if(landswim < ls)
17056 {
17057 if(mx<0||my<0);
17058 else if(mx>248);
17059 else if(mx>240);
17060 else if(my>168);
17061 else if(get_bit(quest_rules, qr_DROWN) && !ilswim);
17062 else if(iswaterex(MAPCOMBO(mx,my), currmap, currscr, -1, mx,my)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
17063 solid = false;
17064 else
17065 solid = true;
17066 }
17067 }
17068 else
17069 {
17070 int32_t wtrx = iswaterex(MAPCOMBO(mx,my), currmap, currscr, -1, mx,my);
17071 int32_t wtrx8 = iswaterex(MAPCOMBO(mx+8,my), currmap, currscr, -1, mx+8,my);
17072
17073 if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
17074 solid = false;
17075 }
17076 }
17077
1/2
✓ Branch 0 taken 49271 times.
✗ Branch 1 not taken.
49271 else if(ladderx+laddery) // ladder is being used
17078 {
17079 int32_t lx = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(mx) : x;
17080 int32_t ly = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(my) : y;
17081
17082 if(ladderdir==up)
17083 {
17084 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
17085 {
17086 bool temp = false;
17087
17088 if(!(abs(lx-(ladderx+8))<=8))
17089 temp = true;
17090
17091 if(!(abs((lx+8)-(ladderx+8))<=8))
17092 temp=true;
17093
17094 if(!temp)
17095 {
17096 solid = false;
17097 }
17098 else if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
17099 {
17100 solid = true;
17101 }
17102 }
17103 }
17104 else
17105 {
17106 if(abs(lx-(ladderx+8))<=8)
17107 {
17108 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
17109 {
17110 solid = false;
17111 }
17112 else if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
17113 {
17114 solid = true;
17115 }
17116 else if((abs(ly-laddery+8)<=8) && d2<=down)
17117 {
17118 solid = false;
17119 }
17120 }
17121 }
17122 }
17123
5/6
✓ Branch 0 taken 42892 times.
✓ Branch 1 taken 6379 times.
✓ Branch 2 taken 15344 times.
✓ Branch 3 taken 27548 times.
✓ Branch 4 taken 15344 times.
✗ Branch 5 not taken.
49271 else if(solid || isSideViewHero() || get_bit(quest_rules, qr_DROWN))
17124 {
17125 // see if it's a good spot for the ladder or for swimming
17126
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49271 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49271 times.
49271 bool unwalkablex = _walkflag(mx,my,1,SWITCHBLOCK_STATE); //will be used later for the ladder -DD
17127
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49271 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49271 times.
49271 bool unwalkablex8 = _walkflag(mx+8,my,1,SWITCHBLOCK_STATE);
17128
17129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49271 times.
49271 if(get_bit(quest_rules, qr_DROWN))
17130 {
17131 // Drowning changes the following attributes:
17132 // * Dangerous water is also walkable, so ignore the previous
17133 // definitions of unwalkablex and unwalkablex8.
17134 // * Instead, prevent the ladder from being used in the
17135 // one frame where Hero has landed on water before drowning.
17136 49271 unwalkablex = unwalkablex8 = !iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11);
17137 49271 }
17138
17139 // check if he can swim
17140
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 49271 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
49271 if(current_item(itype_flippers) && z==0 && fakez==0)
17141 {
17142 int32_t wtrx = iswaterex(MAPCOMBO(mx,my), currmap, currscr, -1, mx,my);
17143 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,my), currmap, currscr, -1, mx+8,my);
17144 if (current_item(itype_flippers) >= combobuf[wtrx8].attribytes[0] && (!(combobuf[wtrx8].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))) //Don't swim if the water's required level is too high! -Dimi
17145 {
17146 //ladder ignores water combos that are now walkable thanks to flippers -DD
17147 unwalkablex = unwalkablex && (!wtrx);
17148 unwalkablex8 = unwalkablex8 && (!wtrx8);
17149
17150 if(landswim >= 22)
17151 {
17152 solid = false;
17153 }
17154 else if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
17155 {
17156 if(dir==d2)
17157 {
17158 ladderx = 0;
17159 laddery = 0;
17160 }
17161 }
17162 }
17163 }
17164
17165 // check if he can use the ladder
17166 // "Allow Ladder Anywhere" is toggled by fLADDER
17167
1/2
✓ Branch 0 taken 49271 times.
✗ Branch 1 not taken.
49271 if(can_deploy_ladder())
17168 // laddersetup
17169 {
17170 // Check if there's water to use the ladder over
17171 bool wtrx = (iswaterex(MAPCOMBO(mx,my), currmap, currscr, -1, mx,my) != 0);
17172 bool wtrx8 = (iswaterex(MAPCOMBO(mx+8,my), currmap, currscr, -1, mx+8,my) != 0);
17173 int32_t ldrid = current_item_id(itype_ladder);
17174 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&ITEM_FLAG1);
17175
17176 if(wtrx || wtrx8)
17177 {
17178 if(isSideViewHero())
17179 {
17180 wtrx = !_walkflag(mx, my+8, 1,SWITCHBLOCK_STATE) && !_walkflag(mx, my, 1,SWITCHBLOCK_STATE) && dir!=down;
17181 wtrx8 = !_walkflag(mx+8, my+8, 1,SWITCHBLOCK_STATE) && !_walkflag(mx+8, my, 1,SWITCHBLOCK_STATE) && dir!=down;
17182 }
17183 // * walk on half-water using the ladder instead of using flippers.
17184 // * otherwise, walk on ladder(+hookshot) combos.
17185 else if(wtrx==wtrx8 && (isstepable(MAPCOMBO(mx, my)) || isstepable(MAPCOMBO(mx+8,my)) || wtrx==true))
17186 {
17187 if(!get_bit(quest_rules, qr_OLD_210_WATER))
17188 {
17189 //if Hero could swim on a tile instead of using the ladder,
17190 //refuse to use the ladder to step over that tile. -DD
17191 wtrx = isstepable(MAPCOMBO(mx, my)) && unwalkablex;
17192 wtrx8 = isstepable(MAPCOMBO(mx+8,my)) && unwalkablex8;
17193 }
17194 }
17195 }
17196 else
17197 {
17198 // No water; check other things
17199
17200 //Check pits
17201 if(ladderpits)
17202 {
17203 int32_t pit_cmb = getpitfall(mx,my);
17204 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
17205 pit_cmb = getpitfall(mx+8,my);
17206 wtrx8 = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
17207 }
17208 if(!ladderpits || (!(wtrx || wtrx8) || isSideViewHero())) //If no pit, check ladder combos
17209 {
17210 int32_t combo=combobuf[MAPCOMBO(mx, my)].type;
17211 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
17212 combo=combobuf[MAPCOMBO(mx+8, my)].type;
17213 wtrx8=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
17214 }
17215 }
17216
17217 for (int32_t i = 0; i <= 1; ++i)
17218 {
17219 if(tmpscr2[i].valid!=0)
17220 {
17221 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
17222 {
17223 if (combobuf[MAPCOMBO2(i,mx,my)].type == cBRIDGE && !_walkflag_layer(mx,my,1, &(tmpscr2[i]))) wtrx = false;
17224 if (combobuf[MAPCOMBO2(i,mx+8,my)].type == cBRIDGE && !_walkflag_layer(mx+8,my,1, &(tmpscr2[i]))) wtrx8 = false;
17225 }
17226 else
17227 {
17228 if (combobuf[MAPCOMBO2(i,mx,my)].type == cBRIDGE && _effectflag_layer(mx,my,1, &(tmpscr2[i]))) wtrx = false;
17229 if (combobuf[MAPCOMBO2(i,mx+8,my)].type == cBRIDGE && _effectflag_layer(mx+8,my,1, &(tmpscr2[i]))) wtrx8 = false;
17230 }
17231 }
17232 }
17233 bool walkwater = (get_bit(quest_rules, qr_DROWN) && !iswaterex(MAPCOMBO(mx,my), currmap, currscr, -1, mx,my));
17234
17235 if(d2==dir)
17236 {
17237 int32_t c = walkwater ? 0:8;
17238 int32_t b = walkwater ? 8:0;
17239
17240 if(d2>=left)
17241 {
17242 // If the difference between my and y is small enough
17243 if(abs((my)-(int32_t(y+c)))<=(b) && wtrx)
17244 {
17245 // Don't activate the ladder if it would be entirely
17246 // over water and Hero has the flippers. This isn't
17247 // a good way to do this, but it's too risky
17248 // to make big changes to this stuff.
17249 bool deployLadder=true;
17250 int32_t lx=mx&0xF0;
17251 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex(MAPCOMBO(lx+8, y+8), currmap, currscr, -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
17252 {
17253 if(iswaterex(MAPCOMBO(lx, y), currmap, currscr, -1, lx, y) &&
17254 iswaterex(MAPCOMBO(lx+15, y), currmap, currscr, -1, lx+15, y) &&
17255 iswaterex(MAPCOMBO(lx, y+15), currmap, currscr, -1, lx, y+15) &&
17256 iswaterex(MAPCOMBO(lx+15, y+15), currmap, currscr, -1, lx+15, y+15))
17257 deployLadder=false;
17258 }
17259 if(deployLadder)
17260 {
17261 ladderx = mx&0xF0;
17262 laddery = y;
17263 ladderdir = left;
17264 ladderstart = d2;
17265 solid = laddery!=y.getInt();
17266 }
17267 }
17268 }
17269 else if(d2<=down)
17270 {
17271 // If the difference between mx and x is small enough
17272 if(abs((mx)-(int32_t(x+c)))<=(b) && wtrx)
17273 {
17274 ladderx = x;
17275 laddery = my&0xF0;
17276 ladderdir = up;
17277 ladderstart = d2;
17278 solid = ladderx!=x.getInt();
17279 }
17280 else if(abs((mx+8)-(int32_t(x+c)))<=(b) && wtrx8)
17281 {
17282 ladderx = x;
17283 laddery = my&0xF0;
17284 ladderdir = up;
17285 ladderstart = d2;
17286 solid = ladderx!=x.getInt();
17287 }
17288 }
17289 }
17290 }
17291 49271 }
17292
17293 49271 return solid;
17294 49271 }
17295
17296 24291 bool HeroClass::scr_canmove(zfix dx, zfix dy, bool kb, bool ign_sv)
17297 {
17298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24291 times.
24291 if(toogam) return true;
17299
3/4
✓ Branch 0 taken 4407 times.
✓ Branch 1 taken 19884 times.
✓ Branch 2 taken 4407 times.
✗ Branch 3 not taken.
24291 if(!(dx || dy)) return true;
17300 24291 zfix bx = x, by = y+(bigHitbox?0:8); //left/top
17301 24291 zfix rx = x+15, ry = y+15; //right/bottom
17302 24291 zfix wid = 16, hei = bigHitbox ? 16 : 8;
17303
6/14
✓ Branch 0 taken 24291 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1910 times.
✓ Branch 3 taken 22381 times.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 1658 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 252 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
24291 if(!ign_sv && dy < 0 && sideview_mode() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17304 return false;
17305
17306 24291 bool nosolid = true;
17307
17308
3/4
✓ Branch 0 taken 19884 times.
✓ Branch 1 taken 4407 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19884 times.
24291 if(dx && !dy)
17309 {
17310
2/2
✓ Branch 0 taken 9563 times.
✓ Branch 1 taken 10321 times.
19884 if(dx < 0)
17311 {
17312 9563 int mx = (bx+dx).getFloor();
17313
2/2
✓ Branch 0 taken 9563 times.
✓ Branch 1 taken 8353 times.
17916 for(zfix ty = 0; by+ty < ry; ty += 8)
17314 {
17315
2/2
✓ Branch 0 taken 8353 times.
✓ Branch 1 taken 1210 times.
9563 if(scr_walkflag(mx, by+ty, left, mx, by, kb))
17316 1210 return false;
17317 8353 }
17318
2/2
✓ Branch 0 taken 823 times.
✓ Branch 1 taken 7530 times.
8353 if(scr_walkflag(mx, ry, left, mx, by, kb))
17319 823 return false;
17320
3/4
✓ Branch 0 taken 7530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3790 times.
✓ Branch 3 taken 3740 times.
7530 if(nosolid && collide_object(bx+dx,by,-dx,hei,this))
17321 3740 return false;
17322 3790 }
17323 else
17324 {
17325 10321 int mx = (rx+dx).getCeil();
17326 10321 int lx = mx-hxsz+1;
17327
2/2
✓ Branch 0 taken 10321 times.
✓ Branch 1 taken 9387 times.
19708 for(zfix ty = 0; by+ty < ry; ty += 8)
17328 {
17329
2/2
✓ Branch 0 taken 9387 times.
✓ Branch 1 taken 934 times.
10321 if(scr_walkflag(mx, by+ty, right, lx, by, kb))
17330 934 return false;
17331 9387 }
17332
2/2
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 8532 times.
9387 if(scr_walkflag(mx, ry, right, lx, by, kb))
17333 855 return false;
17334
3/4
✓ Branch 0 taken 8532 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5489 times.
✓ Branch 3 taken 3043 times.
8532 if(nosolid && collide_object(bx+wid,by,dx,hei,this))
17335 3043 return false;
17336 }
17337 9279 }
17338
2/4
✓ Branch 0 taken 4407 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4407 times.
4407 else if(dy && !dx)
17339 {
17340
2/2
✓ Branch 0 taken 1910 times.
✓ Branch 1 taken 2497 times.
4407 if(dy < 0)
17341 {
17342 1910 int my = (by+dy).getFloor();
17343
2/2
✓ Branch 0 taken 3244 times.
✓ Branch 1 taken 1059 times.
4303 for(zfix tx = 0; bx+tx < rx; tx += 8)
17344 {
17345
2/2
✓ Branch 0 taken 2393 times.
✓ Branch 1 taken 851 times.
3244 if(scr_walkflag(bx+tx, my, up, bx, my, kb))
17346 851 return false;
17347 2393 }
17348
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1042 times.
1059 if(scr_walkflag(rx, my, up, bx, my, kb))
17349 17 return false;
17350
2/4
✓ Branch 0 taken 1042 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1042 times.
✗ Branch 3 not taken.
1042 if(nosolid && collide_object(bx,by+dy,wid,-dy,this))
17351 return false;
17352 1042 }
17353 else
17354 {
17355 2497 int my = (ry+dy).getCeil();
17356 2497 int ly = my-hysz+1;
17357
2/2
✓ Branch 0 taken 4015 times.
✓ Branch 1 taken 1343 times.
5358 for(zfix tx = 0; bx+tx < rx; tx += 8)
17358 {
17359
2/2
✓ Branch 0 taken 2861 times.
✓ Branch 1 taken 1154 times.
4015 if(scr_walkflag(bx+tx, my, down, bx, ly, kb))
17360 1154 return false;
17361 2861 }
17362
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 1250 times.
1343 if(scr_walkflag(rx, my, down, bx, ly, kb))
17363 93 return false;
17364
3/4
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 956 times.
1250 if(nosolid && collide_object(bx,by+hei,wid,dy,this))
17365 294 return false;
17366 }
17367 1998 }
17368 else //! Untested, and currently unused.
17369 {
17370 return scr_canmove(dx, 0, kb, ign_sv) && scr_canmove(dy, 0, kb, ign_sv);
17371 }
17372 11277 return true;
17373 24291 }
17374 11473 bool HeroClass::movexy(zfix dx, zfix dy, bool kb, bool ign_sv, bool shove, bool earlyret)
17375 {
17376 11473 bool ret = true;
17377
7/10
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7802 times.
✓ Branch 3 taken 3671 times.
✓ Branch 4 taken 7476 times.
✓ Branch 5 taken 326 times.
✓ Branch 6 taken 7476 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 7476 times.
11473 bool sv = !ign_sv && sideview_mode() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking;
17378
2/2
✓ Branch 0 taken 3997 times.
✓ Branch 1 taken 7476 times.
11473 if(sv)
17379 7476 dy = 0;
17380
4/4
✓ Branch 0 taken 9747 times.
✓ Branch 1 taken 1726 times.
✓ Branch 2 taken 8648 times.
✓ Branch 3 taken 1099 times.
11473 if(dx && dy)
17381 1099 shove = false;
17382 11473 bool checkladder = dy < 0;
17383
17384 11473 const int scl = 2;
17385
2/4
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11473 times.
11473 while(abs(dx) > scl || abs(dy) > scl)
17386 {
17387 if(abs(dx) > abs(dy))
17388 {
17389 int32_t tdx = dx.sign() * scl;
17390 if(movexy(tdx, 0, kb, ign_sv, shove, earlyret))
17391 dx -= tdx;
17392 else
17393 {
17394 if(earlyret) return false;
17395 dx = tdx;
17396 ret = false;
17397 }
17398 }
17399 else
17400 {
17401 int32_t tdy = dy.sign() * scl;
17402 if(movexy(0, tdy, kb, ign_sv, shove, earlyret))
17403 dy -= tdy;
17404 else
17405 {
17406 if(earlyret) return false;
17407 dy = tdy;
17408 ret = false;
17409 }
17410 }
17411 }
17412
17413
6/8
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 216 times.
✓ Branch 3 taken 11257 times.
✓ Branch 4 taken 10893 times.
✓ Branch 5 taken 364 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 10893 times.
11473 bool skipdmg = earlyret || hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS));
17414
2/2
✓ Branch 0 taken 1726 times.
✓ Branch 1 taken 9747 times.
11473 if(dx)
17415 {
17416
2/2
✓ Branch 0 taken 9109 times.
✓ Branch 1 taken 638 times.
9747 if(scr_canmove(dx, 0, kb, ign_sv))
17417 9109 x += dx;
17418 else
17419 {
17420 638 bool stopped = true;
17421
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 582 times.
638 if(shove)
17422 {
17423
2/2
✓ Branch 0 taken 313 times.
✓ Branch 1 taken 269 times.
582 zfix tx = (dx < 0 ? (x-1) : (x+16));
17424 582 auto mdir = GET_XDIR(dx);
17425 582 bool hit_top = scr_walkflag(tx,y,mdir,x+sign(dx),y,false);
17426 582 bool hit_mid = scr_walkflag(tx,y+8,mdir,x+sign(dx),y,false);
17427 582 bool hit_bottom = scr_walkflag(tx,y+15,mdir,x+sign(dx),y,false);
17428
4/4
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 468 times.
✓ Branch 3 taken 22 times.
582 if(!hit_mid && (hit_top!=hit_bottom))
17429 {
17430
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1 times.
22 if(hit_bottom) //shove up
17431 {
17432
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
21 if(skipdmg || !checkdamagecombos(tx,y+15))
17433 21 y -= 1;
17434 21 }
17435 else //shove down
17436 {
17437
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(skipdmg || !checkdamagecombos(tx,y))
17438 1 y += 1;
17439 }
17440
17441
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 5 times.
22 if(scr_canmove(dx, 0, kb, ign_sv))
17442 {
17443 5 x += dx;
17444 5 stopped = false;
17445 5 }
17446 22 }
17447 582 }
17448
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 633 times.
638 if(stopped)
17449 {
17450 633 ret = false;
17451 633 int xsign = dx.sign();
17452
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 633 times.
676 while(scr_canmove(xsign, 0, kb, ign_sv))
17453 {
17454 43 x += xsign;
17455 43 dx -= xsign;
17456 }
17457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 633 times.
633 if(dx)
17458 {
17459 633 dx.doDecBound(0,-9999, 0,9999);
17460
3/6
✓ Branch 0 taken 633 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 633 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 633 times.
✗ Branch 5 not taken.
10072 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
17461
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 9317 times.
9439 if(scr_canmove(val, 0, kb, ign_sv))
17462 {
17463 122 retval = val;
17464 122 return BSEARCH_CONTINUE_AWAY0;
17465 }
17466 9317 else return BSEARCH_CONTINUE_TOWARD0;
17467 9439 });
17468 633 x += dx;
17469 633 }
17470 633 }
17471 }
17472 9747 }
17473
2/2
✓ Branch 0 taken 9439 times.
✓ Branch 1 taken 2034 times.
11473 if(dy)
17474 {
17475
2/2
✓ Branch 0 taken 1884 times.
✓ Branch 1 taken 150 times.
2034 if(scr_canmove(0, dy, kb, ign_sv))
17476 1884 y += dy;
17477 else
17478 {
17479 150 bool stopped = true;
17480
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 80 times.
150 if(shove)
17481 {
17482
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 45 times.
80 zfix ty = (dy < 0 ? (y+(bigHitbox?0:8)-1) : (y+16));
17483 80 auto mdir = GET_YDIR(dy);
17484 80 bool hit_left = scr_walkflag(x,ty,mdir,x,y+sign(dy),false);
17485 80 bool hit_mid = scr_walkflag(x+8,ty,mdir,x,y+sign(dy),false);
17486 80 bool hit_right = scr_walkflag(x+15,ty,mdir,x,y+sign(dy),false);
17487
4/4
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 20 times.
80 if(!hit_mid && (hit_left!=hit_right))
17488 {
17489
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 if(hit_right) //shove left
17490 {
17491
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
16 if(skipdmg || !checkdamagecombos(x+15,ty))
17492 16 x -= 1;
17493 16 }
17494 else //shove right
17495 {
17496
3/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1 times.
4 if(skipdmg || !checkdamagecombos(x,ty))
17497 1 x += 1;
17498 }
17499
17500
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1 times.
20 if(scr_canmove(0, dy, kb, ign_sv))
17501 {
17502 1 y += dy;
17503 1 stopped = false;
17504 1 }
17505 20 }
17506 80 }
17507
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 149 times.
150 if(stopped)
17508 {
17509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if(earlyret) return false;
17510 149 ret = false;
17511 149 int ysign = dy.sign();
17512
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 149 times.
153 while(scr_canmove(0, ysign, kb, ign_sv))
17513 {
17514 4 y += ysign;
17515 4 dy -= ysign;
17516 }
17517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if(dy)
17518 {
17519 149 dy.doDecBound(0,-9999, 0,9999);
17520
3/6
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
2349 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
17521
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 2091 times.
2200 if(scr_canmove(0, val, kb, ign_sv))
17522 {
17523 109 retval = val;
17524 109 return BSEARCH_CONTINUE_AWAY0;
17525 }
17526 2091 else return BSEARCH_CONTINUE_TOWARD0;
17527 2200 });
17528 149 y += dy;
17529 149 }
17530 149 }
17531 }
17532 2034 }
17533
17534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11473 times.
11473 if(earlyret)
17535 return ret;
17536 11473 WalkflagInfo info;
17537 11473 info = walkflag(x,y+8-(bigHitbox*8)-4,2,up);
17538 11473 execute(info);
17539
4/8
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7802 times.
✓ Branch 3 taken 3671 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7802 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
11473 if(!ign_sv && sideview_mode() && IsSideSwim() && checkladder)
17540 {
17541 if(!iswaterex(MAPCOMBO(x, y+(bigHitbox?0:8)), currmap, currscr, -1, x, y+(bigHitbox?0:8) - 2, true, false)
17542 && !canSideviewLadderRemote(x, y-4) && !info.isUnwalkable() && (y+(bigHitbox?0:8) - 4) > 0)
17543 {
17544 if (game->get_sideswim_jump() != 0)
17545 {
17546 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
17547 sfx(WAV_ZN1SPLASH,(int32_t)x);
17548 hopclk = 0;
17549 if (charging || spins) action = attacking;
17550 else action = none;
17551 }
17552 else
17553 {
17554 movexy(0,-1*dy,false,false,false);
17555 }
17556 }
17557 }
17558 11473 return ret;
17559 11473 }
17560 bool HeroClass::can_movexy(zfix dx, zfix dy, bool kb, bool ign_sv, bool shove)
17561 {
17562 zfix ox(x),oy(y);
17563 bool ret = movexy(dx,dy,kb,ign_sv,shove,true);
17564 x = ox;
17565 y = oy;
17566 return ret;
17567 }
17568
17569 15396 bool HeroClass::premove()
17570 {
17571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15396 times.
15396 if(lstunclock) return false;
17572
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15396 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15396 if(is_conveyor_stunned) return (convey_forcex || convey_forcey);
17573 15396 int32_t xoff=x.getInt()&7;
17574 15396 int32_t yoff=y.getInt()&7;
17575
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15396 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15396 if(NO_GRIDLOCK)
17576 {
17577 15396 xoff = 0;
17578 15396 yoff = 0;
17579 15396 }
17580 15396 int32_t push=pushing;
17581 15396 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
17582 15396 int32_t flippers_id = current_item_id(itype_flippers);
17583 15396 itemdata const& itm = itemsbuf[flippers_id];
17584 15396 byte intbtn = byte(itm.misc3&0xFF);
17585 15396 bool dive_pressed = getIntBtnInput(intbtn, true, true, false, false, true);
17586 15396 bool eatdive = false;
17587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15396 times.
15396 if(diveclk>0)
17588 {
17589 if (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM)) diveclk = 0;
17590 --diveclk;
17591 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && dive_pressed) //Cancellable Diving -V
17592 {
17593 diveclk = itemsbuf[flippers_id].misc2;
17594 eatdive = true;
17595 }
17596 }
17597
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15396 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15396 else if(action == swimming && dive_pressed)
17598 {
17599 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
17600 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
17601
17602 if(global_diving==screen_diving)
17603 {
17604 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
17605 eatdive = true;
17606 }
17607 }
17608
1/2
✓ Branch 0 taken 15396 times.
✗ Branch 1 not taken.
15396 if(eatdive)
17609 getIntBtnInput(intbtn, true, true, false, false, false);
17610
17611
1/2
✓ Branch 0 taken 15396 times.
✗ Branch 1 not taken.
15396 if(action==rafting)
17612 {
17613 do_rafting();
17614
17615 if(action==rafting)
17616 {
17617 return false;
17618 }
17619
17620
17621 set_respawn_point();
17622 trySideviewLadder();
17623 }
17624
17625 15396 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
17626 15396 int32_t btnwpn = -1;
17627
17628 //&0xFFF removes the "bow & arrows" bitmask
17629 //The Quick Sword is allowed to interrupt attacks.
17630
3/4
✓ Branch 0 taken 15396 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1947 times.
✓ Branch 3 taken 13449 times.
15396 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
17631
2/8
✓ Branch 0 taken 15396 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15396 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
15396 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5)))
17632 {
17633
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 15312 times.
15396 if(DrunkrBbtn())
17634 {
17635 84 btnwpn=getItemFamily(itemsbuf,Bwpn&0xFFF);
17636 84 dowpn = Bwpn&0xFFF;
17637 84 directWpn = directItemB;
17638 84 }
17639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15312 times.
15312 else if(DrunkrAbtn())
17640 {
17641 btnwpn=getItemFamily(itemsbuf,Awpn&0xFFF);
17642 dowpn = Awpn&0xFFF;
17643 directWpn = directItemA;
17644 }
17645
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15312 else if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
17646 {
17647 btnwpn=getItemFamily(itemsbuf,Xwpn&0xFFF);
17648 dowpn = Xwpn&0xFFF;
17649 directWpn = directItemX;
17650 }
17651
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15312 else if(get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
17652 {
17653 btnwpn=getItemFamily(itemsbuf,Ywpn&0xFFF);
17654 dowpn = Ywpn&0xFFF;
17655 directWpn = directItemY;
17656 }
17657
17658
1/2
✓ Branch 0 taken 15396 times.
✗ Branch 1 not taken.
15396 if(directWpn > 255) directWpn = 0;
17659
17660 // The Quick Sword only allows repeated sword or wand swings.
17661
3/8
✓ Branch 0 taken 15396 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15396 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 15396 times.
15396 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
17662 btnwpn=-1;
17663 15396 }
17664
17665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15396 times.
15396 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
17666
2/12
✓ Branch 0 taken 15396 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15396 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
15396 if(can_attack() && (swordid > -1 && itemsbuf[swordid].family==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
17667 {
17668 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
17669 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & ITEM_FLAG6)))
17670 {
17671 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
17672 {
17673 paymagiccost(attackid,true);
17674 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
17675 }
17676 SetAttack();
17677 attack=wSword;
17678
17679 attackclk=0;
17680 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x.getInt()));
17681
17682 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(item_doscript[dowpn] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
17683 {
17684 if(!checkmagiccost(dowpn))
17685 {
17686 item_error();
17687 }
17688 else
17689 {
17690 //clear the item script stack for a new script
17691
17692 ri = &(itemScriptData[dowpn]);
17693 for ( int32_t q = 0; q < 1024; q++ ) item_stack[dowpn][q] = 0xFFFF;
17694 ri->Clear();
17695 //itemScriptData[(dowpn & 0xFFF)].Clear();
17696 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(dowpn & 0xFFF)][q] = 0;
17697 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn & 0xFFF);
17698 item_doscript[dowpn] = 1;
17699 itemscriptInitialised[dowpn] = 0;
17700 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn);
17701 did_scripta=true;
17702 }
17703 }
17704 }
17705 else
17706 {
17707 item_error();
17708 }
17709 }
17710 else
17711 {
17712 15396 did_scripta=false;
17713 }
17714
17715
6/10
✓ Branch 0 taken 15396 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15396 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15396 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15396 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 319 times.
✓ Branch 9 taken 15077 times.
15396 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
17716 {
17717
4/4
✓ Branch 0 taken 1574 times.
✓ Branch 1 taken 13503 times.
✓ Branch 2 taken 1567 times.
✓ Branch 3 taken 7 times.
15077 if(DrunkUp() && canSideviewLadder())
17718 {
17719 7 setOnSideviewLadder(true);
17720 7 }
17721
4/4
✓ Branch 0 taken 2783 times.
✓ Branch 1 taken 12287 times.
✓ Branch 2 taken 2781 times.
✓ Branch 3 taken 2 times.
15070 else if(DrunkDown() && canSideviewLadder(true))
17722 {
17723 2 y+=1;
17724 2 setOnSideviewLadder(true);
17725 2 }
17726 15077 }
17727
17728 15396 int32_t wx=x;
17729 15396 int32_t wy=y;
17730
5/6
✓ Branch 0 taken 9339 times.
✓ Branch 1 taken 6057 times.
✓ Branch 2 taken 328 times.
✓ Branch 3 taken 15068 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 328 times.
15396 if((action==none || action==walking) && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
17731 {
17732
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 328 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
328 if((xoff==0)||diagonalMovement)
17733 {
17734
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 254 times.
328 if(DrunkUp()) dir=up;
17735
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 74 times.
328 if(DrunkDown()) dir=down;
17736 328 }
17737
17738
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 328 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
328 if((yoff==0)||diagonalMovement)
17739 {
17740
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 52 times.
328 if(DrunkLeft()) dir=left;
17741
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 40 times.
328 if(DrunkRight()) dir=right;
17742 328 }
17743 328 }
17744
17745
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1034 times.
✓ Branch 2 taken 2701 times.
✓ Branch 3 taken 4795 times.
✓ Branch 4 taken 6866 times.
15396 switch(dir)
17746 {
17747 case up:
17748 1034 wy-=16;
17749 1034 break;
17750
17751 case down:
17752 2701 wy+=16;
17753 2701 break;
17754
17755 case left:
17756 4795 wx-=16;
17757 4795 break;
17758
17759 case right:
17760 6866 wx+=16;
17761 6866 break;
17762 }
17763
17764 15396 do_lens();
17765
17766 15396 bool no_jinx = true;
17767
5/8
✓ Branch 0 taken 15396 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 15312 times.
✓ Branch 4 taken 84 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 84 times.
15396 if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
17768 {
17769 84 bool paidmagic = false;
17770
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
17771
2/10
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
84 if(!liftonly && btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_wand : false) : current_item(itype_wand)))
17772 {
17773 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
17774 no_jinx = checkitem_jinx(attackid);
17775 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
17776 {
17777 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
17778 paymagiccost(attackid,true);
17779 misc_internal_hero_flags |= LF_PAID_WAND_COST;
17780 }
17781 SetAttack();
17782 attack=wWand;
17783 attackclk=0;
17784 }
17785 else
17786 {
17787 item_error();
17788 }
17789 }
17790
2/8
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
84 else if(!liftonly && (btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
17791 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_hammer : false) : current_item(itype_hammer)))
17792 {
17793 no_jinx = checkitem_jinx(dowpn);
17794 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
17795 {
17796 item_error();
17797 }
17798 else
17799 {
17800 paymagiccost(dowpn);
17801 paidmagic = true;
17802 SetAttack();
17803 attack=wHammer;
17804 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
17805 attackclk=0;
17806 }
17807 }
17808
2/8
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
84 else if(!liftonly && (btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
17809 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_candle : false) : current_item(itype_candle)))
17810 {
17811 //checkbunny handled where magic cost is paid
17812 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
17813 no_jinx = checkitem_jinx(attackid);
17814 if(no_jinx)
17815 {
17816 SetAttack();
17817 attack=wFire;
17818 attackclk=0;
17819 }
17820 }
17821
2/8
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
84 else if(!liftonly && (btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
17822 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_cbyrna : false) : current_item(itype_cbyrna)))
17823 {
17824 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
17825 no_jinx = checkitem_jinx(attackid);
17826 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
17827 {
17828 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
17829 paymagiccost(attackid,true);
17830 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
17831 }
17832 SetAttack();
17833 attack=wCByrna;
17834 attackclk=0;
17835 }
17836 else
17837 {
17838 item_error();
17839 }
17840 }
17841
2/8
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
84 else if(!liftonly && (btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
17842 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].family==itype_bugnet) : current_item(itype_bugnet)))
17843 {
17844 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
17845 no_jinx = checkitem_jinx(attackid);
17846 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
17847 {
17848 paymagiccost(attackid);
17849 SetAttack();
17850 attack = wBugNet;
17851 attackclk = 0;
17852 sfx(itemsbuf[attackid].usesound);
17853 }
17854 else
17855 {
17856 item_error();
17857 }
17858 }
17859 else
17860 {
17861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
17862 84 no_jinx = checkitem_jinx(itmid);
17863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if(no_jinx)
17864 {
17865 84 paidmagic = startwpn(itmid);
17866
17867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if(paidmagic)
17868 {
17869 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
17870 {
17871 ;
17872 }
17873 else
17874 {
17875 SetAttack();
17876 attackclk=0;
17877 attack=none;
17878
17879 if(btnwpn==itype_brang)
17880 {
17881 attack=wBrang;
17882 }
17883 }
17884 }
17885 else
17886 {
17887 // Weapon not started: directWpn should be reset to prev. value.
17888 84 directWpn = olddirectwpn;
17889 }
17890 84 }
17891 }
17892
17893
3/12
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 84 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
84 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(item_doscript[dowpn] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
17894 {
17895 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
17896 {
17897 item_error();
17898 }
17899 else
17900 {
17901 // Only charge for magic if item's magic cost wasn't already charged
17902 // for the item's main use.
17903 if(!paidmagic && attack!=wWand)
17904 paymagiccost(dowpn);
17905 //clear the item script stack for a new script
17906 //itemScriptData[(dowpn & 0xFFF)].Clear();
17907 ri = &(itemScriptData[dowpn]);
17908 for ( int32_t q = 0; q < 1024; q++ ) item_stack[dowpn][q] = 0xFFFF;
17909 ri->Clear();
17910 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(dowpn & 0xFFF)][q] = 0;
17911 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn & 0xFFF);
17912 item_doscript[dowpn] = 1;
17913 itemscriptInitialised[dowpn] = 0;
17914 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn);
17915 did_scriptb=true;
17916 }
17917 }
17918
17919
6/12
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 84 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 84 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 84 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 84 times.
84 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
17920 {
17921 return false;
17922 }
17923
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(!no_jinx)
17924 did_scriptb = false;
17925 84 }
17926 else
17927 {
17928 15312 did_scriptb=false;
17929 }
17930
17931
3/6
✓ Branch 0 taken 15396 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15396 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 15396 times.
15396 if(attackclk || action==attacking || action==sideswimattacking)
17932 {
17933
17934 if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
17935 {
17936 if((xoff==0)||diagonalMovement)
17937 {
17938 if(DrunkUp()) dir=up;
17939 if(DrunkDown()) dir=down;
17940 }
17941
17942 if((yoff==0)||diagonalMovement)
17943 {
17944 if(DrunkLeft()) dir=left;
17945 if(DrunkRight()) dir=right;
17946 }
17947 }
17948
17949 bool attacked = doattack();
17950
17951 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
17952 if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
17953 {
17954 if((xoff==0)||diagonalMovement)
17955 {
17956 if(DrunkUp()) dir=up;
17957
17958 if(DrunkDown()) dir=down;
17959 }
17960
17961 if((yoff==0)||diagonalMovement)
17962 {
17963 if(DrunkLeft()) dir=left;
17964
17965 if(DrunkRight()) dir=right;
17966 }
17967 }
17968
17969 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
17970 {
17971 return false;
17972 }
17973 else if(!attacked)
17974 {
17975 // Spin attack - change direction
17976 if(spins>1 && attack != wHammer)
17977 {
17978 spins--;
17979
17980 if(spins%5==0)
17981 {
17982 int id = currentscroll > -1 ? currentscroll : (current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll));
17983 sfx(itemsbuf[id].usesound,pan(x.getInt()));
17984 }
17985 attackclk=1;
17986
17987 switch(dir)
17988 {
17989 case up:
17990 dir=left;
17991 break;
17992
17993 case right:
17994 dir=up;
17995 break;
17996
17997 case down:
17998 dir=right;
17999 break;
18000
18001 case left:
18002 dir=down;
18003 break;
18004 }
18005
18006 return false;
18007 }
18008 else
18009 {
18010 spins=0;
18011 }
18012
18013 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
18014 else {action=none; FFCore.setHeroAction(none);}
18015 attackclk=0;
18016 charging=0;
18017 }
18018 }
18019 15396 return true;
18020 15396 }
18021 15396 void HeroClass::movehero()
18022 {
18023 15396 WalkflagInfo info;
18024 15396 int32_t xoff=x.getInt()&7;
18025 15396 int32_t yoff=y.getInt()&7;
18026
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15396 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15396 if(NO_GRIDLOCK)
18027 {
18028 15396 xoff = 0;
18029 15396 yoff = 0;
18030 15396 }
18031 15396 auto push=pushing;
18032 15396 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
18033 15396 pushing=0;
18034
18035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15396 times.
15396 if(!is_conveyor_stunned) //these do not apply to conveyor auto-walk
18036 {
18037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15396 times.
15396 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
18038 return;
18039
18040
2/2
✓ Branch 0 taken 6057 times.
✓ Branch 1 taken 9339 times.
15396 if(action==walking) //still walking
18041 {
18042
9/10
✓ Branch 0 taken 7678 times.
✓ Branch 1 taken 1661 times.
✓ Branch 2 taken 5229 times.
✓ Branch 3 taken 2449 times.
✓ Branch 4 taken 3065 times.
✓ Branch 5 taken 2164 times.
✓ Branch 6 taken 166 times.
✓ Branch 7 taken 2899 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 166 times.
9339 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
18043 {
18044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
166 if(attackclk>0) SetAttack();
18045 166 else {action = none; FFCore.setHeroAction(none);}
18046 166 hero_count=-1;
18047 166 return;
18048 }
18049
18050 9173 autostep=false;
18051 9173 } // endif (action==walking)
18052
18053
13/24
✓ Branch 0 taken 15230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15230 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15230 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15230 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15230 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 15230 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 15230 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 15230 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 15230 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 15230 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 15230 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 2595 times.
✓ Branch 23 taken 12635 times.
15230 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
18054 {
18055 12635 action=none; FFCore.setHeroAction(none);
18056 12635 }
18057 15230 }
18058
18059
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 15230 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
15230 bool nohorz = (isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam);
18060
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 15230 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
15230 bool novert = (isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam);
18061
18062 15230 zfix dx, dy;
18063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15230 times.
15230 if(is_conveyor_stunned)
18064 {
18065 dx = convey_forcex;
18066 dy = convey_forcey;
18067 convey_forcex = 0;
18068 convey_forcey = 0;
18069 if(action != walking)
18070 {
18071 action = walking; FFCore.setHeroAction(walking);
18072 }
18073 }
18074
1/2
✓ Branch 0 taken 15230 times.
✗ Branch 1 not taken.
15230 else if(diagonalMovement)
18075 {
18076
5/5
✓ Branch 0 taken 3757 times.
✓ Branch 1 taken 864 times.
✓ Branch 2 taken 2013 times.
✓ Branch 3 taken 3551 times.
✓ Branch 4 taken 5045 times.
15230 switch(holddir)
18077 {
18078 case up:
18079
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 31 times.
864 if(!Up())
18080 {
18081 31 holddir=-1;
18082 31 }
18083
18084 864 break;
18085
18086 case down:
18087
2/2
✓ Branch 0 taken 1974 times.
✓ Branch 1 taken 39 times.
2013 if(!Down())
18088 {
18089 39 holddir=-1;
18090 39 }
18091
18092 2013 break;
18093
18094 case left:
18095
2/2
✓ Branch 0 taken 3444 times.
✓ Branch 1 taken 107 times.
3551 if(!Left())
18096 {
18097 107 holddir=-1;
18098 107 }
18099
18100 3551 break;
18101
18102 case right:
18103
2/2
✓ Branch 0 taken 4906 times.
✓ Branch 1 taken 139 times.
5045 if(!Right())
18104 {
18105 139 holddir=-1;
18106 139 }
18107
18108 5045 break;
18109
18110 default:
18111 3757 break;
18112 } //end switch
18113
18114
6/6
✓ Branch 0 taken 1821 times.
✓ Branch 1 taken 13409 times.
✓ Branch 2 taken 1790 times.
✓ Branch 3 taken 31 times.
✓ Branch 4 taken 833 times.
✓ Branch 5 taken 864 times.
15230 if(DrunkUp()&&(holddir==-1||holddir==up)&&!novert)
18115 {
18116
4/10
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 864 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 864 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 864 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
864 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
18117 {
18118 864 dir=up;
18119 864 }
18120 864 holddir=up;
18121
18122
5/6
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 734 times.
✓ Branch 2 taken 129 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 129 times.
864 if(DrunkRight()&&shiftdir!=left&&!nohorz)
18123 {
18124 129 shiftdir=right;
18125
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
129 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
18126
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
18127 129 }
18128
4/6
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 643 times.
✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 92 times.
735 else if(DrunkLeft()&&shiftdir!=right&&!nohorz)
18129 {
18130 92 shiftdir=left;
18131
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
92 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
18132
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
92 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
18133 92 }
18134 else
18135 {
18136 643 shiftdir=-1;
18137 }
18138 864 }
18139
6/6
✓ Branch 0 taken 2855 times.
✓ Branch 1 taken 13177 times.
✓ Branch 2 taken 2816 times.
✓ Branch 3 taken 39 times.
✓ Branch 4 taken 842 times.
✓ Branch 5 taken 2013 times.
16032 else if(DrunkDown()&&(holddir==-1||holddir==down)&&!novert)
18140 {
18141
4/10
✓ Branch 0 taken 2013 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2013 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2013 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2013 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2013 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
18142 {
18143 2013 dir=down;
18144 2013 }
18145 2013 holddir=down;
18146
18147
5/6
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 1491 times.
✓ Branch 2 taken 516 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 516 times.
2013 if(DrunkRight()&&shiftdir!=left&&!nohorz)
18148 {
18149 516 shiftdir=right;
18150
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 516 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
516 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
18151
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 516 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
516 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
18152 516 }
18153
5/6
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 1081 times.
✓ Branch 2 taken 414 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 414 times.
1497 else if(DrunkLeft()&&shiftdir!=right&&!nohorz)
18154 {
18155 414 shiftdir=left;
18156
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 414 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
414 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
18157
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 414 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
414 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
18158 414 }
18159 else
18160 {
18161 1083 shiftdir=-1;
18162 }
18163 2013 }
18164
6/6
✓ Branch 0 taken 3571 times.
✓ Branch 1 taken 10448 times.
✓ Branch 2 taken 3464 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 3551 times.
14019 else if(DrunkLeft()&&(holddir==-1||holddir==left)&&!nohorz)
18165 {
18166
3/6
✓ Branch 0 taken 3551 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3551 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3551 times.
3551 if(charging==0 && spins==0 && action != sideswimattacking)
18167 {
18168 3551 dir=left;
18169 3551 }
18170 3551 sideswimdir = left;
18171 3551 holddir=left;
18172
18173
4/6
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 3141 times.
✓ Branch 2 taken 410 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 410 times.
3551 if(DrunkUp()&&shiftdir!=down&&!novert)
18174 {
18175 410 shiftdir=up;
18176 410 }
18177
4/6
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 2827 times.
✓ Branch 2 taken 314 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 314 times.
3141 else if(DrunkDown()&&shiftdir!=up&&!novert)
18178 {
18179 314 shiftdir=down;
18180 314 }
18181 else
18182 {
18183 2827 shiftdir=-1;
18184 }
18185 3551 }
18186
5/6
✓ Branch 0 taken 5045 times.
✓ Branch 1 taken 5423 times.
✓ Branch 2 taken 4906 times.
✓ Branch 3 taken 139 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5045 times.
10468 else if(DrunkRight()&&(holddir==-1||holddir==right)&&!nohorz)
18187 {
18188
3/6
✓ Branch 0 taken 5045 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5045 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5045 times.
5045 if(charging==0 && spins==0 && action != sideswimattacking)
18189 {
18190 5045 dir=right;
18191 5045 }
18192 5045 sideswimdir = right;
18193 5045 holddir=right;
18194
18195
4/6
✓ Branch 0 taken 547 times.
✓ Branch 1 taken 4498 times.
✓ Branch 2 taken 547 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 547 times.
5045 if(DrunkUp()&&shiftdir!=down&&!novert)
18196 {
18197 547 shiftdir=up;
18198 547 }
18199
4/6
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3970 times.
✓ Branch 2 taken 528 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 528 times.
4498 else if(DrunkDown()&&shiftdir!=up&&!novert)
18200 {
18201 528 shiftdir=down;
18202 528 }
18203 else
18204 {
18205 3970 shiftdir=-1;
18206 }
18207 5045 }
18208 else
18209 {
18210
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5423 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5423 if(shield_forcedir > -1 && action != rafting)
18211 dir = shield_forcedir;
18212 5423 int32_t wtry = iswaterex(MAPCOMBO(x,y+15), currmap, currscr, -1, x,y+15, true, false);
18213 5423 int32_t wtry8 = iswaterex(MAPCOMBO(x+15,y+15), currmap, currscr, -1, x+15,y+15, true, false);
18214 5423 int32_t wtrx = iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)), currmap, currscr, -1, x,y+(bigHitbox?0:8), true, false);
18215 5423 int32_t wtrx8 = iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)), currmap, currscr, -1, x+15,y+(bigHitbox?0:8), true, false);
18216 5423 int32_t wtrc = iswaterex(MAPCOMBO(x+8,y+(bigHitbox?8:12)), currmap, currscr, -1, x+8,y+(bigHitbox?8:12), true, false);
18217
18218
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 5423 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
5423 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))&&!(ladderx+laddery)&&z==0&&fakez==0)
18219 {
18220 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
18221 {
18222 //action=swimming;
18223 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
18224 {
18225 hopclk = 0xFF;
18226 }
18227 }
18228 }
18229 5423 return;
18230 }
18231 11473 get_move(holddir,dx,dy);
18232 11473 }
18233 else //4-way
18234 {
18235 shiftdir = -1;
18236 if(!novert)
18237 {
18238 if(DrunkUp())
18239 {
18240 holddir = dir = up;
18241 }
18242 else if(DrunkDown())
18243 {
18244 holddir = dir = down;
18245 }
18246 }
18247 else if(!nohorz)
18248 {
18249 if(DrunkLeft())
18250 {
18251 holddir = dir = left;
18252 }
18253 else if(DrunkRight())
18254 {
18255 holddir = dir = right;
18256 }
18257 }
18258 get_move(holddir,dx,dy);
18259 }
18260
18261
2/2
✓ Branch 0 taken 10691 times.
✓ Branch 1 taken 782 times.
11473 if(!new_engine_move(dx,dy))
18262 782 pushing = push+1;
18263 17062 }
18264
18265 19075 void HeroClass::get_move(int movedir, zfix& dx, zfix& dy)
18266 {
18267 19075 dx = 0; dy = 0;
18268
5/6
✓ Branch 0 taken 11473 times.
✓ Branch 1 taken 7602 times.
✓ Branch 2 taken 11473 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7602 times.
✓ Branch 5 taken 19075 times.
19075 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
18269 15204 return;
18270
18271 19075 zfix base_movepix(zfix(steprate) / 100);
18272 19075 zfix movepix(base_movepix);
18273 19075 zfix up_step(zfix(game->get_sideswim_up()) / 100);
18274 19075 zfix left_step(zfix(game->get_sideswim_side()) / 100);
18275 19075 zfix right_step(zfix(game->get_sideswim_side()) / 100);
18276 19075 zfix down_step(zfix(game->get_sideswim_down()) / 100);
18277 19075 std::vector<zfix*> steps;
18278
2/2
✓ Branch 0 taken 11473 times.
✓ Branch 1 taken 7602 times.
19075 steps.push_back(&movepix);
18279
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 steps.push_back(&up_step);
18280
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 steps.push_back(&left_step);
18281
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 steps.push_back(&right_step);
18282
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 steps.push_back(&down_step);
18283
18284
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 mod_steps(steps);
18285
18286
2/4
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11473 times.
✗ Branch 3 not taken.
11473 up_step = -up_step;
18287
2/4
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11473 times.
✗ Branch 3 not taken.
11473 left_step = -left_step;
18288
18289
18290
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 zfix step(movepix);
18291
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 zfix step_diag(movepix);
18292
18293
18294
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 if (diagonalMovement)
18295 {
18296 //zprint2("Player's X is %d, Y is %d\n", x, y);
18297
6/6
✓ Branch 0 taken 10609 times.
✓ Branch 1 taken 864 times.
✓ Branch 2 taken 2049 times.
✓ Branch 3 taken 12658 times.
✓ Branch 4 taken 2371 times.
✓ Branch 5 taken 542 times.
19112 if (((movedir == up || movedir == down) && (shiftdir == left || shiftdir == right)) ||
18298
4/4
✓ Branch 0 taken 6771 times.
✓ Branch 1 taken 5887 times.
✓ Branch 2 taken 1752 times.
✓ Branch 3 taken 8523 times.
12658 (movedir == left || movedir == right) && (shiftdir == up || shiftdir == down))
18299 {
18300
4/6
✓ Branch 0 taken 2950 times.
✓ Branch 1 taken 7602 times.
✓ Branch 2 taken 2950 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2950 times.
✗ Branch 5 not taken.
10552 step = STEP_DIAGONAL(step);
18301
3/6
✓ Branch 0 taken 2950 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2950 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2950 times.
✗ Branch 5 not taken.
2950 up_step = STEP_DIAGONAL(up_step);
18302
3/6
✓ Branch 0 taken 2950 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2950 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2950 times.
✗ Branch 5 not taken.
2950 left_step = STEP_DIAGONAL(left_step);
18303
3/6
✓ Branch 0 taken 2950 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2950 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2950 times.
✗ Branch 5 not taken.
2950 right_step = STEP_DIAGONAL(right_step);
18304
3/6
✓ Branch 0 taken 2950 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2950 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2950 times.
✗ Branch 5 not taken.
2950 down_step = STEP_DIAGONAL(down_step);
18305 2950 }
18306
4/5
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 2013 times.
✓ Branch 2 taken 3551 times.
✓ Branch 3 taken 5045 times.
✗ Branch 4 not taken.
11473 switch (movedir)
18307 {
18308 case up:
18309
3/3
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 129 times.
✓ Branch 2 taken 643 times.
864 switch (shiftdir)
18310 {
18311 case left:
18312
4/10
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 92 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 92 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 92 times.
✗ Branch 9 not taken.
92 dx = IsSideSwim() ? left_step : -step;
18313 92 break;
18314 case right:
18315
3/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
✓ Branch 4 taken 129 times.
✗ Branch 5 not taken.
129 dx = IsSideSwim() ? right_step : step;
18316 129 break;
18317 }
18318
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
864 if (IsSideSwim())
18319 {
18320 dy = up_step;
18321 }
18322
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 864 times.
✗ Branch 3 not taken.
864 else dy = -step;
18323 864 break;
18324 case down:
18325
3/3
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 1083 times.
2013 switch (shiftdir)
18326 {
18327 case left:
18328
2/4
✓ Branch 0 taken 414 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 414 times.
✗ Branch 3 not taken.
414 dx = -step;
18329
2/6
✓ Branch 0 taken 414 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 414 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
414 if (IsSideSwim()) dx = left_step;
18330 414 break;
18331 case right:
18332
1/2
✓ Branch 0 taken 516 times.
✗ Branch 1 not taken.
516 dx = step;
18333
2/6
✓ Branch 0 taken 516 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 516 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
516 if (IsSideSwim()) dx = right_step;
18334 516 break;
18335 }
18336
3/6
✓ Branch 0 taken 2013 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2013 times.
✓ Branch 4 taken 2013 times.
✗ Branch 5 not taken.
2013 dy = IsSideSwim() ? down_step : step;
18337 2013 break;
18338 case left:
18339
3/3
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 314 times.
✓ Branch 2 taken 2827 times.
3551 switch (shiftdir)
18340 {
18341 case up:
18342
2/4
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 410 times.
410 if (IsSideSwim())
18343 {
18344 dy = up_step;
18345 }
18346
2/4
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 410 times.
✗ Branch 3 not taken.
410 else dy = -step;
18347 410 break;
18348 case down:
18349
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 dy = step;
18350
2/6
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 314 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
314 if (IsSideSwim()) dy = down_step;
18351 314 break;
18352 }
18353
4/10
✓ Branch 0 taken 3551 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3551 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 3551 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3551 times.
✗ Branch 9 not taken.
3551 dx = IsSideSwim() ? left_step : -step;
18354 3551 break;
18355 case right:
18356
3/3
✓ Branch 0 taken 547 times.
✓ Branch 1 taken 528 times.
✓ Branch 2 taken 3970 times.
5045 switch (shiftdir)
18357 {
18358 case up:
18359
4/8
✓ Branch 0 taken 547 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 547 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 547 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 547 times.
✗ Branch 7 not taken.
547 if (!IsSideSwim()) dy = -step;
18360
2/4
✓ Branch 0 taken 547 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 547 times.
547 if (IsSideSwim())
18361 {
18362 dy = up_step;
18363 }
18364 547 break;
18365 case down:
18366
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 dy = step;
18367
2/6
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528 if (IsSideSwim()) dy = down_step;
18368 528 break;
18369 }
18370
3/6
✓ Branch 0 taken 5045 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5045 times.
✓ Branch 4 taken 5045 times.
✗ Branch 5 not taken.
5045 dx = IsSideSwim() ? right_step : step;
18371 5045 break;
18372 };
18373 11473 }
18374 else
18375 {
18376 switch (movedir)
18377 {
18378 case up:
18379 dy = IsSideSwim() ? up_step : -step;
18380 break;
18381 case down:
18382 dy = IsSideSwim() ? down_step : step;
18383 break;
18384 case left:
18385 dx = IsSideSwim() ? left_step : -step;
18386 break;
18387 case right:
18388 dx = IsSideSwim() ? right_step : step;
18389 break;
18390 };
18391 }
18392
18393
6/20
✗ Branch 0 not taken.
✓ Branch 1 taken 11473 times.
✓ Branch 2 taken 11473 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11473 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11473 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 11473 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 11473 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
11473 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (movedir == up || movedir == down))) //!DIRECTION SET
18394 {
18395 11473 dir=movedir;
18396 11473 }
18397 else if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (movedir == up || movedir == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
18398 {
18399 dir = shiftdir;
18400 }
18401 26677 }
18402
18403 11473 bool HeroClass::new_engine_move(zfix dx, zfix dy) //no collision check
18404 {
18405
3/4
✓ Branch 0 taken 1726 times.
✓ Branch 1 taken 9747 times.
✓ Branch 2 taken 1726 times.
✗ Branch 3 not taken.
11473 if(!dx && !dy) return true;
18406
4/8
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11473 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11473 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 11473 times.
11473 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
18407 {
18408 11473 herostep();
18409
18410 //ack... don't walk if in midair! -DD
18411
11/14
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11473 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11109 times.
✓ Branch 5 taken 364 times.
✓ Branch 6 taken 11109 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7802 times.
✓ Branch 9 taken 3307 times.
✓ Branch 10 taken 2164 times.
✓ Branch 11 taken 5638 times.
✓ Branch 12 taken 324 times.
✓ Branch 13 taken 1840 times.
11473 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
18412 {
18413 9269 action=walking; FFCore.setHeroAction(walking);
18414 9269 }
18415
18416
2/2
✓ Branch 0 taken 10873 times.
✓ Branch 1 taken 600 times.
11473 if(++hero_count > (16*hero_animation_speed))
18417 600 hero_count=0;
18418 11473 }
18419 else if(!(frame & 1))
18420 {
18421 herostep();
18422 }
18423
18424 11473 bool ret = true;
18425
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11473 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11473 if(charging==0 || attack!=wHammer)
18426 {
18427 11473 ret = movexy(dx,dy,false,false,true);
18428 11473 }
18429 11473 return ret;
18430 11473 }
18431
18432 3357396 void HeroClass::moveOld(int32_t d2)
18433 {
18434 //al_trace("%s\n",d2==up?"up":d2==down?"down":d2==left?"left":d2==right?"right":"?");
18435 static bool totalskip = false;
18436
18437
3/6
✓ Branch 0 taken 3357396 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3357396 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3357396 times.
3357396 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
18438 return;
18439
18440 3357396 int32_t dx=0,dy=0;
18441 3357396 int32_t xstep=lsteps[x.getInt()&7];
18442 3357396 int32_t ystep=lsteps[y.getInt()&7];
18443 3357396 int32_t z3skip=0;
18444 3357396 int32_t z3diagskip=0;
18445
3/6
✓ Branch 0 taken 77205 times.
✓ Branch 1 taken 3280191 times.
✓ Branch 2 taken 77205 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6637587 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && ((z==0 && fakez == 0) || tmpscr->flags2&fAIRCOMBOS)) ||
18446
5/6
✓ Branch 0 taken 149353 times.
✓ Branch 1 taken 3130838 times.
✓ Branch 2 taken 81755 times.
✓ Branch 3 taken 67598 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 81755 times.
3280191 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement);
18447
2/2
✓ Branch 0 taken 3356810 times.
✓ Branch 1 taken 586 times.
3357396 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
18448 3357396 bool is_swimming = (action == swimming);
18449
18450 //slow walk combo, or charging, moves at 2/3 speed
18451 if(
18452
4/4
✓ Branch 0 taken 3310583 times.
✓ Branch 1 taken 46813 times.
✓ Branch 2 taken 77568 times.
✓ Branch 3 taken 3233015 times.
3404209 (!is_swimming && (slowcharging ^ slowcombo))||
18453
2/2
✓ Branch 0 taken 46813 times.
✓ Branch 1 taken 3233015 times.
3279828 (is_swimming && (zinit.hero_swim_speed>60))
18454 )
18455 {
18456 124381 totalskip = false;
18457
18458
2/2
✓ Branch 0 taken 5817 times.
✓ Branch 1 taken 118564 times.
124381 if(diagonalMovement)
18459 {
18460 5817 skipstep=(skipstep+1)%6;
18461
18462
2/2
✓ Branch 0 taken 2945 times.
✓ Branch 1 taken 2872 times.
5817 if(skipstep%2==0) z3skip=1;
18463 2945 else z3skip=0;
18464
18465
2/2
✓ Branch 0 taken 3919 times.
✓ Branch 1 taken 1898 times.
5817 if(skipstep%3==0) z3diagskip=1;
18466 3919 else z3diagskip=0;
18467 5817 }
18468 else
18469 {
18470
2/2
✓ Branch 0 taken 79518 times.
✓ Branch 1 taken 39046 times.
118564 if(d2<left)
18471 {
18472
2/2
✓ Branch 0 taken 48027 times.
✓ Branch 1 taken 31491 times.
79518 if(ystep>1)
18473 {
18474 31491 skipstep^=1;
18475 31491 ystep=skipstep;
18476 31491 }
18477 79518 }
18478 else
18479 {
18480
2/2
✓ Branch 0 taken 23745 times.
✓ Branch 1 taken 15301 times.
39046 if(xstep>1)
18481 {
18482 15301 skipstep^=1;
18483 15301 xstep=skipstep;
18484 15301 }
18485 }
18486 }
18487 124381 }
18488 // else if(is_swimming || (slowcharging && slowcombo))
18489 else if(
18490
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3233015 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3233126 (is_swimming && (zinit.hero_swim_speed<60))||
18491
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 3232904 times.
3233015 (slowcharging && slowcombo)
18492 )
18493 {
18494 //swimming, or charging on a slow combo, moves at 1/2 speed
18495 111 totalskip = !totalskip;
18496
18497
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(diagonalMovement)
18498 {
18499 skipstep=0;
18500 }
18501 111 }
18502 else
18503 {
18504 3232904 totalskip = false;
18505
18506
2/2
✓ Branch 0 taken 2921881 times.
✓ Branch 1 taken 311023 times.
3232904 if(diagonalMovement)
18507 {
18508 311023 skipstep=0;
18509 311023 }
18510 }
18511
18512
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 3357340 times.
3357396 if(!totalskip)
18513 {
18514
2/2
✓ Branch 0 taken 316840 times.
✓ Branch 1 taken 3040500 times.
3357340 if(diagonalMovement)
18515 {
18516
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 42924 times.
✓ Branch 2 taken 28497 times.
✓ Branch 3 taken 134155 times.
✓ Branch 4 taken 111264 times.
316840 switch(d2)
18517 {
18518 case up:
18519
2/2
✓ Branch 0 taken 3502 times.
✓ Branch 1 taken 39422 times.
42924 if(shiftdir==left)
18520 {
18521
2/2
✓ Branch 0 taken 2238 times.
✓ Branch 1 taken 1264 times.
3502 if(walkable)
18522 {
18523 2238 dy-=1-z3diagskip;
18524 2238 dx-=1-z3diagskip;
18525 2238 z3step=2;
18526 2238 }
18527 else
18528 {
18529 1264 dx-=1-z3diagskip;
18530 1264 z3step=2;
18531 }
18532 3502 }
18533
2/2
✓ Branch 0 taken 4597 times.
✓ Branch 1 taken 34825 times.
39422 else if(shiftdir==right)
18534 {
18535
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 1732 times.
4597 if(walkable)
18536 {
18537 2865 dy-=1-z3diagskip;
18538 2865 dx+=1-z3diagskip;
18539 2865 z3step=2;
18540 2865 }
18541 else
18542 {
18543 1732 dx+=1-z3diagskip;
18544 1732 z3step=2;
18545 }
18546 4597 }
18547 else
18548 {
18549
2/2
✓ Branch 0 taken 16422 times.
✓ Branch 1 taken 18403 times.
34825 if(walkable)
18550 {
18551 18403 dy-=z3step-z3skip;
18552 18403 z3step=(z3step%2)+1;
18553 18403 }
18554 }
18555
18556 42924 break;
18557
18558 case down:
18559
2/2
✓ Branch 0 taken 3039 times.
✓ Branch 1 taken 25458 times.
28497 if(shiftdir==left)
18560 {
18561
2/2
✓ Branch 0 taken 1696 times.
✓ Branch 1 taken 1343 times.
3039 if(walkable)
18562 {
18563 1696 dy+=1-z3diagskip;
18564 1696 dx-=1-z3diagskip;
18565 1696 z3step=2;
18566 1696 }
18567 else
18568 {
18569 1343 dx-=1-z3diagskip;
18570 1343 z3step=2;
18571 }
18572 3039 }
18573
2/2
✓ Branch 0 taken 3600 times.
✓ Branch 1 taken 21858 times.
25458 else if(shiftdir==right)
18574 {
18575
2/2
✓ Branch 0 taken 2488 times.
✓ Branch 1 taken 1112 times.
3600 if(walkable)
18576 {
18577 2488 dy+=1-z3diagskip;
18578 2488 dx+=1-z3diagskip;
18579 2488 z3step=2;
18580 2488 }
18581 else
18582 {
18583 1112 dx+=1-z3diagskip;
18584 1112 z3step=2;
18585 }
18586 3600 }
18587 else
18588 {
18589
2/2
✓ Branch 0 taken 9004 times.
✓ Branch 1 taken 12854 times.
21858 if(walkable)
18590 {
18591 12854 dy+=z3step-z3skip;
18592 12854 z3step=(z3step%2)+1;
18593 12854 }
18594 }
18595
18596 28497 break;
18597
18598 case right:
18599
2/2
✓ Branch 0 taken 129352 times.
✓ Branch 1 taken 4803 times.
134155 if(shiftdir==up)
18600 {
18601
2/2
✓ Branch 0 taken 4409 times.
✓ Branch 1 taken 394 times.
4803 if(walkable)
18602 {
18603 4409 dy-=1-z3diagskip;
18604 4409 dx+=1-z3diagskip;
18605 4409 z3step=2;
18606 4409 }
18607 else
18608 {
18609 394 dy-=1-z3diagskip;
18610 394 z3step=2;
18611 }
18612 4803 }
18613
2/2
✓ Branch 0 taken 3813 times.
✓ Branch 1 taken 125539 times.
129352 else if(shiftdir==down)
18614 {
18615
2/2
✓ Branch 0 taken 3363 times.
✓ Branch 1 taken 450 times.
3813 if(walkable)
18616 {
18617 3363 dy+=1-z3diagskip;
18618 3363 dx+=1-z3diagskip;
18619 3363 z3step=2;
18620 3363 }
18621 else
18622 {
18623 450 dy+=1-z3diagskip;
18624 450 z3step=2;
18625 }
18626 3813 }
18627 else
18628 {
18629
2/2
✓ Branch 0 taken 13252 times.
✓ Branch 1 taken 112287 times.
125539 if(walkable)
18630 {
18631 112287 dx+=z3step-z3skip;
18632 112287 z3step=(z3step%2)+1;
18633 112287 }
18634 }
18635
18636 134155 break;
18637
18638 case left:
18639
2/2
✓ Branch 0 taken 107496 times.
✓ Branch 1 taken 3768 times.
111264 if(shiftdir==up)
18640 {
18641
2/2
✓ Branch 0 taken 3458 times.
✓ Branch 1 taken 310 times.
3768 if(walkable)
18642 {
18643 3458 dy-=1-z3diagskip;
18644 3458 dx-=1-z3diagskip;
18645 3458 z3step=2;
18646 3458 }
18647 else
18648 {
18649 310 dy-=1-z3diagskip;
18650 310 z3step=2;
18651 }
18652 3768 }
18653
2/2
✓ Branch 0 taken 3104 times.
✓ Branch 1 taken 104392 times.
107496 else if(shiftdir==down)
18654 {
18655
2/2
✓ Branch 0 taken 2823 times.
✓ Branch 1 taken 281 times.
3104 if(walkable)
18656 {
18657 2823 dy+=1-z3diagskip;
18658 2823 dx-=1-z3diagskip;
18659 2823 z3step=2;
18660 2823 }
18661 else
18662 {
18663 281 dy+=1-z3diagskip;
18664 281 z3step=2;
18665 }
18666 3104 }
18667 else
18668 {
18669
2/2
✓ Branch 0 taken 12264 times.
✓ Branch 1 taken 92128 times.
104392 if(walkable)
18670 {
18671 92128 dx-=z3step-z3skip;
18672 92128 z3step=(z3step%2)+1;
18673 92128 }
18674 }
18675
18676 111264 break;
18677 }
18678 316840 }
18679 else
18680 {
18681
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 711843 times.
✓ Branch 2 taken 581911 times.
✓ Branch 3 taken 840304 times.
✓ Branch 4 taken 906442 times.
3040500 switch(d2)
18682 {
18683 case up:
18684
7/14
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 711535 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 308 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 308 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 308 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 308 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
711843 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy-=ystep;
18685
18686 711843 break;
18687
18688 case down:
18689
7/14
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 581857 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 54 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 54 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 54 times.
581911 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy+=ystep;
18690
18691 581911 break;
18692
18693 case left:
18694 840304 dx-=xstep;
18695 840304 break;
18696
18697 case right:
18698 906442 dx+=xstep;
18699 906442 break;
18700 }
18701 }
18702 3357340 }
18703
18704
8/16
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 3356810 times.
✓ Branch 2 taken 3356531 times.
✓ Branch 3 taken 865 times.
✓ Branch 4 taken 3356335 times.
✓ Branch 5 taken 196 times.
✓ Branch 6 taken 3356335 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 3356335 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
3357396 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
18705 {
18706 3356335 dir=d2;
18707 3356335 }
18708
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1061 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1061 else if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
18709 {
18710 dir = shiftdir;
18711 }
18712
18713
3/4
✓ Branch 0 taken 3310583 times.
✓ Branch 1 taken 46813 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3310583 times.
3357396 if(action != swimming && !IsSideSwim())
18714 {
18715 3310583 herostep();
18716
18717 //ack... don't walk if in midair! -DD
18718
12/14
✓ Branch 0 taken 3309997 times.
✓ Branch 1 taken 586 times.
✓ Branch 2 taken 3309718 times.
✓ Branch 3 taken 279 times.
✓ Branch 4 taken 3309558 times.
✓ Branch 5 taken 160 times.
✓ Branch 6 taken 3309558 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 149353 times.
✓ Branch 9 taken 3160205 times.
✓ Branch 10 taken 81755 times.
✓ Branch 11 taken 67598 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 81755 times.
3310583 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
18719 {
18720 3227803 action=walking; FFCore.setHeroAction(walking);
18721 3227803 }
18722
18723
2/2
✓ Branch 0 taken 3136400 times.
✓ Branch 1 taken 174183 times.
3310583 if(++hero_count > (16*hero_animation_speed))
18724 174183 hero_count=0;
18725 3310583 }
18726
2/2
✓ Branch 0 taken 23410 times.
✓ Branch 1 taken 23403 times.
46813 else if(!(frame & 1))
18727 {
18728 23403 herostep();
18729 23403 }
18730
18731
3/4
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 3356810 times.
✓ Branch 2 taken 586 times.
✗ Branch 3 not taken.
3357396 if(charging==0 || attack!=wHammer)
18732 {
18733 3357396 sprite::move((zfix)dx,(zfix)dy);
18734 3357396 }
18735 3357396 }
18736 3437786 void HeroClass::moveOld2(int32_t d2, int32_t forceRate)
18737 {
18738
4/6
✓ Branch 0 taken 3437471 times.
✓ Branch 1 taken 315 times.
✓ Branch 2 taken 3437471 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3437471 times.
3437786 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
18739 315 return;
18740
18741
3/4
✓ Branch 0 taken 3357396 times.
✓ Branch 1 taken 80075 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3357396 times.
3437471 if(!get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) && !IsSideSwim())
18742 {
18743 3357396 moveOld(d2);
18744 3357396 return;
18745 }
18746
18747
4/8
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 77099 times.
✓ Branch 2 taken 2976 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2976 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
157174 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1) && ((z==0 && fakez==0) || tmpscr->flags2&fAIRCOMBOS)) ||
18748
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 77099 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
77099 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1));
18749 //!DIMITODO: add QR for slow combos under hero
18750
4/4
✓ Branch 0 taken 77099 times.
✓ Branch 1 taken 2976 times.
✓ Branch 2 taken 2976 times.
✓ Branch 3 taken 5952 times.
86027 if(slowcombo) for (int32_t i = 0; i <= 1; ++i)
18751 {
18752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5952 times.
5952 if(tmpscr2[i].valid!=0)
18753 {
18754
1/2
✓ Branch 0 taken 5952 times.
✗ Branch 1 not taken.
5952 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18755 {
18756
2/4
✓ Branch 0 taken 5952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5952 times.
✗ Branch 3 not taken.
5952 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && !_walkflag_layer(x+7,y+8,1, &(tmpscr2[i])))
18757 {
18758 slowcombo = false;
18759 break;
18760 }
18761 5952 }
18762 else
18763 {
18764 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && _effectflag_layer(x+7,y+8,1, &(tmpscr2[i])))
18765 {
18766 slowcombo = false;
18767 break;
18768 }
18769 }
18770 5952 }
18771 8928 }
18772
1/2
✓ Branch 0 taken 80075 times.
✗ Branch 1 not taken.
80075 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
18773 80075 bool is_swimming = (action == swimming);
18774 80075 bool fastSwim = (zinit.hero_swim_speed>60);
18775 80075 zfix rate(steprate);
18776 80075 int32_t shieldid = getCurrentActiveShield();
18777
1/2
✓ Branch 0 taken 80075 times.
✗ Branch 1 not taken.
80075 if(shieldid > -1)
18778 {
18779 itemdata const& shield = itemsbuf[shieldid];
18780 if(shield.flags & ITEM_FLAG10) //Change Speed flag
18781 {
18782 zfix perc = shield.misc7;
18783 perc /= 100;
18784 if(perc < 0)
18785 perc = (perc*-1)+1;
18786 rate = (rate * perc) + shield.misc8;
18787 }
18788 }
18789
18790 80075 zfix dx, dy;
18791 80075 zfix movepix(rate / 100);
18792 80075 zfix step(movepix);
18793 80075 zfix step_diag(movepix);
18794 80075 zfix up_step(game->get_sideswim_up() / -100.0);
18795 80075 zfix left_step(game->get_sideswim_side() / -100.0);
18796 80075 zfix right_step(game->get_sideswim_side() / 100.0);
18797 80075 zfix down_step(game->get_sideswim_down() / 100.0);
18798 80075 bool checkladder = false;
18799
18800
2/2
✓ Branch 0 taken 80074 times.
✓ Branch 1 taken 1 times.
80075 if(hero_newstep > movepix) hero_newstep = movepix;
18801
2/2
✓ Branch 0 taken 80074 times.
✓ Branch 1 taken 1 times.
80075 if(hero_newstep_diag > movepix) hero_newstep_diag = movepix;
18802 //2/3 speed
18803
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80075 times.
✓ Branch 2 taken 77099 times.
✓ Branch 3 taken 77099 times.
✓ Branch 4 taken 80075 times.
✓ Branch 5 taken 77099 times.
80075 if((is_swimming && fastSwim) || (!is_swimming && (slowcharging ^ slowcombo)))
18804 {
18805 157174 step = ((step / 3.0) * 2);
18806 157174 step_diag = ((step_diag / 3.0) * 2);
18807 157174 up_step = ((up_step / 3.0) * 2);
18808 157174 left_step = ((left_step / 3.0) * 2);
18809 157174 right_step = ((right_step / 3.0) * 2);
18810 157174 down_step = ((down_step / 3.0) * 2);
18811 157174 }
18812 //1/2 speed
18813
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 77099 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 77099 times.
77099 else if((is_swimming && !fastSwim) || (slowcharging && slowcombo))
18814 {
18815 step /= 2;
18816 step_diag /= 2;
18817 up_step /= 2;
18818 left_step /= 2;
18819 right_step /= 2;
18820 down_step /= 2;
18821 }
18822 //normal speed
18823 else
18824 {
18825 //no modification
18826 }
18827
18828
1/2
✓ Branch 0 taken 80075 times.
✗ Branch 1 not taken.
80075 if(diagonalMovement)
18829 {
18830 //zprint2("Player's X is %d, Y is %d\n", x, y);
18831
6/6
✓ Branch 0 taken 63320 times.
✓ Branch 1 taken 16755 times.
✓ Branch 2 taken 65924 times.
✓ Branch 3 taken 3260 times.
✓ Branch 4 taken 29126 times.
✓ Branch 5 taken 53553 times.
121896 if(((d2 == up || d2 == down) && (shiftdir == left || shiftdir == right)) ||
18832
4/4
✓ Branch 0 taken 49618 times.
✓ Branch 1 taken 46358 times.
✓ Branch 2 taken 4757 times.
✓ Branch 3 taken 44861 times.
3260 (d2 == left || d2 == right) && (shiftdir == up || shiftdir == down))
18833 {
18834
2/4
✓ Branch 0 taken 17394 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17394 times.
124500 if(hero_newstep > 0 && hero_newstep_diag > 0)
18835 {
18836 17394 step = STEP_DIAGONAL(step);
18837 17394 step_diag = STEP_DIAGONAL(step_diag);
18838 17394 up_step = STEP_DIAGONAL(up_step);
18839 17394 left_step = STEP_DIAGONAL(left_step);
18840 17394 right_step = STEP_DIAGONAL(right_step);
18841 17394 down_step = STEP_DIAGONAL(down_step);
18842 17394 }
18843 17394 }
18844
2/2
✓ Branch 0 taken 56055 times.
✓ Branch 1 taken 6200 times.
62255 if(hero_newstep < step) step = hero_newstep; //handle collision
18845
2/2
✓ Branch 0 taken 59652 times.
✓ Branch 1 taken 2603 times.
62255 if(hero_newstep_diag < step_diag) step_diag = hero_newstep_diag; //handle collision
18846
5/5
✓ Branch 0 taken 17820 times.
✓ Branch 1 taken 16755 times.
✓ Branch 2 taken 16283 times.
✓ Branch 3 taken 22736 times.
✓ Branch 4 taken 24301 times.
62255 switch(d2)
18847 {
18848 case up:
18849
3/3
✓ Branch 0 taken 13317 times.
✓ Branch 1 taken 1751 times.
✓ Branch 2 taken 1687 times.
16755 switch(shiftdir)
18850 {
18851 case left:
18852 1751 dx = -step_diag;
18853
1/2
✓ Branch 0 taken 1751 times.
✗ Branch 1 not taken.
1751 if (IsSideSwim()) dx = left_step;
18854 1751 break;
18855 case right:
18856 1687 dx = step_diag;
18857
1/2
✓ Branch 0 taken 1687 times.
✗ Branch 1 not taken.
1687 if (IsSideSwim()) dx = right_step;
18858 1687 break;
18859 }
18860
2/2
✓ Branch 0 taken 2320 times.
✓ Branch 1 taken 14435 times.
16755 if(walkable)
18861 {
18862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14435 times.
14435 if (!IsSideSwim()) dy = -step;
18863
1/2
✓ Branch 0 taken 14435 times.
✗ Branch 1 not taken.
14435 if (IsSideSwim())
18864 {
18865 dy = up_step;
18866 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
18867 }
18868 14435 }
18869 16755 break;
18870 case down:
18871
3/3
✓ Branch 0 taken 12000 times.
✓ Branch 1 taken 2161 times.
✓ Branch 2 taken 2122 times.
16283 switch(shiftdir)
18872 {
18873 case left:
18874 2161 dx = -step_diag;
18875
1/2
✓ Branch 0 taken 2161 times.
✗ Branch 1 not taken.
2161 if (IsSideSwim()) dx = left_step;
18876 2161 break;
18877 case right:
18878 2122 dx = step_diag;
18879
1/2
✓ Branch 0 taken 2122 times.
✗ Branch 1 not taken.
2122 if (IsSideSwim()) dx = right_step;
18880 2122 break;
18881 }
18882
2/2
✓ Branch 0 taken 1611 times.
✓ Branch 1 taken 14672 times.
16283 if(walkable)
18883 {
18884 14672 dy = step;
18885
1/2
✓ Branch 0 taken 14672 times.
✗ Branch 1 not taken.
14672 if (IsSideSwim()) dy = down_step;
18886 14672 }
18887 16283 break;
18888 case left:
18889
3/3
✓ Branch 0 taken 17900 times.
✓ Branch 1 taken 2701 times.
✓ Branch 2 taken 2135 times.
22736 switch(shiftdir)
18890 {
18891 case up:
18892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2701 times.
2701 if (!IsSideSwim()) dy = -step_diag;
18893
1/2
✓ Branch 0 taken 2701 times.
✗ Branch 1 not taken.
2701 if (IsSideSwim())
18894 {
18895 dy = up_step;
18896 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
18897 }
18898 2701 break;
18899 case down:
18900 2135 dy = step_diag;
18901
1/2
✓ Branch 0 taken 2135 times.
✗ Branch 1 not taken.
2135 if (IsSideSwim()) dy = down_step;
18902 2135 break;
18903 }
18904
2/2
✓ Branch 0 taken 2405 times.
✓ Branch 1 taken 20331 times.
22736 if(walkable)
18905 {
18906 20331 dx = -step;
18907
1/2
✓ Branch 0 taken 20331 times.
✗ Branch 1 not taken.
20331 if (IsSideSwim()) dx = left_step;
18908 20331 }
18909 22736 break;
18910 case right:
18911
3/3
✓ Branch 0 taken 19464 times.
✓ Branch 1 taken 2515 times.
✓ Branch 2 taken 2322 times.
24301 switch(shiftdir)
18912 {
18913 case up:
18914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2515 times.
2515 if (!IsSideSwim()) dy = -step_diag;
18915
1/2
✓ Branch 0 taken 2515 times.
✗ Branch 1 not taken.
2515 if (IsSideSwim())
18916 {
18917 dy = up_step;
18918 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
18919 }
18920 2515 break;
18921 case down:
18922 2322 dy = step_diag;
18923
1/2
✓ Branch 0 taken 2322 times.
✗ Branch 1 not taken.
2322 if (IsSideSwim()) dy = down_step;
18924 2322 break;
18925 }
18926
2/2
✓ Branch 0 taken 2418 times.
✓ Branch 1 taken 21883 times.
24301 if(walkable)
18927 {
18928 21883 dx = step;
18929
1/2
✓ Branch 0 taken 21883 times.
✗ Branch 1 not taken.
21883 if (IsSideSwim()) dx = right_step;
18930 21883 }
18931 24301 break;
18932 };
18933 97895 }
18934 else
18935 {
18936 if(hero_newstep < step) step = hero_newstep; //handle collision
18937 switch(d2)
18938 {
18939 case up:
18940 dy -= step;
18941 if (IsSideSwim()) dy = up_step;
18942 break;
18943 case down:
18944 dy += step;
18945 if (IsSideSwim()) dy = down_step;
18946 break;
18947 case left:
18948 dx -= step;
18949 if (IsSideSwim()) dx = left_step;
18950 break;
18951 case right:
18952 dx += step;
18953 if (IsSideSwim()) dx = right_step;
18954 break;
18955 };
18956 }
18957 97895 hero_newstep = movepix;
18958 97895 hero_newstep_diag = movepix;
18959
18960
6/16
✗ Branch 0 not taken.
✓ Branch 1 taken 97895 times.
✓ Branch 2 taken 80075 times.
✓ Branch 3 taken 17820 times.
✓ Branch 4 taken 80075 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 80075 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 80075 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
97895 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
18961 {
18962 80075 dir=d2;
18963 80075 }
18964
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 17820 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
17820 else if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
18965 {
18966 dir = shiftdir;
18967 }
18968
2/2
✓ Branch 0 taken 97883 times.
✓ Branch 1 taken 12 times.
97895 if(forceRate > -1)
18969 {
18970 12 checkladder = false;
18971
1/3
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
12 switch(dir)
18972 {
18973 case right:
18974 case r_up:
18975 case r_down:
18976 12 dx = zfix(forceRate) / 100;
18977 12 break;
18978 case left:
18979 case l_up:
18980 case l_down:
18981 dx = zfix(-forceRate) / 100;
18982 break;
18983 default:
18984 dx = 0;
18985 }
18986
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
12 switch(dir)
18987 {
18988 case down:
18989 case r_down:
18990 case l_down:
18991 dy = zfix(forceRate) / 100;
18992 break;
18993 case up:
18994 case r_up:
18995 case l_up:
18996 dy = zfix(-forceRate) / 100;
18997 break;
18998 default:
18999 12 dy = 0;
19000 12 }
19001 12 }
19002
4/4
✓ Branch 0 taken 30140 times.
✓ Branch 1 taken 67755 times.
✓ Branch 2 taken 23928 times.
✓ Branch 3 taken 6212 times.
97895 if(dx == 0 && dy == 0) return;
19003
5/8
✓ Branch 0 taken 73863 times.
✓ Branch 1 taken 17820 times.
✓ Branch 2 taken 73863 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 73863 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 73863 times.
91683 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
19004 {
19005 73863 herostep();
19006
19007 //ack... don't walk if in midair! -DD
19008
5/14
✓ Branch 0 taken 73863 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 73863 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 73863 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 73863 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 73863 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
73863 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
19009 {
19010 73863 action=walking; FFCore.setHeroAction(walking);
19011 73863 }
19012
19013
2/2
✓ Branch 0 taken 70086 times.
✓ Branch 1 taken 3777 times.
73863 if(++hero_count > (16*hero_animation_speed))
19014 3777 hero_count=0;
19015 73863 }
19016
1/2
✓ Branch 0 taken 17820 times.
✗ Branch 1 not taken.
17820 else if(!(frame & 1))
19017 {
19018 herostep();
19019 }
19020
19021
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 91683 times.
✓ Branch 2 taken 17820 times.
✓ Branch 3 taken 17820 times.
91683 if(charging==0 || attack!=wHammer)
19022 {
19023 109503 sprite::move(dx, dy);
19024 109503 WalkflagInfo info;
19025 109503 info = walkflag(x,y+8-(bigHitbox*8)-4,2,up);
19026 109503 execute(info);
19027
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 73863 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 73863 times.
✗ Branch 7 not taken.
109503 if (checkladder && !canSideviewLadderRemote(x, y-4) && !info.isUnwalkable() && (y + 8 - (bigHitbox * 8) - 4) > 0)
19028 {
19029 if (game->get_sideswim_jump() != 0)
19030 {
19031 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
19032 sfx(WAV_ZN1SPLASH,(int32_t)x);
19033 hopclk = 0;
19034 if (charging || spins) action = attacking;
19035 else action = none;
19036 }
19037 else
19038 {
19039 sprite::move(zfix(0), zfix(-1*dy));
19040 }
19041 }
19042 73863 }
19043 3455606 }
19044
19045 15695935 HeroClass::WalkflagInfo HeroClass::walkflag(zfix fx,zfix fy,int32_t cnt,byte d2)
19046 {
19047 15695935 return walkflag(fx.getInt(), fy.getInt(), cnt, d2);
19048 }
19049 15695935 HeroClass::WalkflagInfo HeroClass::walkflag(int32_t wx,int32_t wy,int32_t cnt,byte d2)
19050 {
19051 15695935 WalkflagInfo ret;
19052
19053 15695935 wx = vbound(wx, -1, 256);
19054 15695935 wy = vbound(wy, -1, 176);
19055
19056
8/8
✓ Branch 0 taken 15627693 times.
✓ Branch 1 taken 68242 times.
✓ Branch 2 taken 15563483 times.
✓ Branch 3 taken 64210 times.
✓ Branch 4 taken 15563452 times.
✓ Branch 5 taken 31 times.
✓ Branch 6 taken 2429 times.
✓ Branch 7 taken 15561023 times.
15695935 if (wx < 0 || wx > 255 || wy < 0 || wy > 175)
19057 {
19058 134912 ret.setUnwalkable(false);
19059 134912 return ret;
19060 }
19061
19062
2/2
✓ Branch 0 taken 41482 times.
✓ Branch 1 taken 15519541 times.
15561023 if(toogam)
19063 {
19064 41482 ret.setUnwalkable(false);
19065 41482 return ret;
19066 }
19067
19068
4/4
✓ Branch 0 taken 319804 times.
✓ Branch 1 taken 15199737 times.
✓ Branch 2 taken 312628 times.
✓ Branch 3 taken 7176 times.
15519541 if(blockpath && wy<(bigHitbox?80:88))
19069 {
19070 7176 ret.setUnwalkable(true);
19071 7176 return ret;
19072 }
19073
19074
4/4
✓ Branch 0 taken 133900 times.
✓ Branch 1 taken 15378465 times.
✓ Branch 2 taken 101869 times.
✓ Branch 3 taken 32031 times.
15512365 if(blockmoving && mblock2.hit(wx,wy,0,1,1,1))
19075 {
19076 32031 ret.setUnwalkable(true);
19077 32031 return ret;
19078 }
19079
19080
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 15480225 times.
15480334 if (collide_object(wx, wy,1, 1))
19081 {
19082 109 ret.setUnwalkable(true);
19083 109 return ret;
19084 }
19085
19086
15/22
✓ Branch 0 taken 9040508 times.
✓ Branch 1 taken 6439717 times.
✓ Branch 2 taken 8719631 times.
✓ Branch 3 taken 320877 times.
✓ Branch 4 taken 8434402 times.
✓ Branch 5 taken 285229 times.
✓ Branch 6 taken 285229 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 285229 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 285229 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 145354 times.
✓ Branch 15 taken 139875 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 139875 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 139875 times.
✓ Branch 20 taken 23842 times.
✓ Branch 21 taken 15456383 times.
15644837 if(isdungeon() && currscr<128 && wy<(bigHitbox?32:40) && (((diagonalMovement||NO_GRIDLOCK)?(x<=112||x>=128):x!=120) || _walkflag(120,24,2,SWITCHBLOCK_STATE))
19087
2/2
✓ Branch 0 taken 19258 times.
✓ Branch 1 taken 120617 times.
285229 && !get_bit(quest_rules,qr_FREEFORM))
19088 {
19089 23842 ret.setUnwalkable(true);
19090 23842 return ret;
19091 }
19092
19093
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15456383 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15456383 times.
15456383 bool wf = _walkflag(wx,wy,cnt,SWITCHBLOCK_STATE);
19094
19095
6/6
✓ Branch 0 taken 9016666 times.
✓ Branch 1 taken 6439717 times.
✓ Branch 2 taken 8695789 times.
✓ Branch 3 taken 320877 times.
✓ Branch 4 taken 2475524 times.
✓ Branch 5 taken 6220265 times.
15456383 if(isdungeon() && currscr<128 && !get_bit(quest_rules,qr_FREEFORM))
19096 {
19097
3/6
✓ Branch 0 taken 6220265 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6220265 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6220265 times.
6220265 if((diagonalMovement||NO_GRIDLOCK))
19098 {
19099 if(wx>=112&&wx<120&&wy<40&&wy>=32) wf=true;
19100
19101 if(wx>=136&&wx<144&&wy<40&&wy>=32) wf=true;
19102 }
19103 6220265 }
19104 //All problems related to exiting water are probably here. -Z
19105
3/4
✓ Branch 0 taken 15114450 times.
✓ Branch 1 taken 341933 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15114450 times.
15456383 if(action==swimming || IsSideSwim())
19106 {
19107
2/2
✓ Branch 0 taken 325082 times.
✓ Branch 1 taken 16851 times.
341933 if(!wf)
19108 {
19109 16851 bool isthissolid = false;
19110
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16851 times.
✓ Branch 2 taken 16851 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4526 times.
✓ Branch 5 taken 12325 times.
21377 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
19111
4/6
✓ Branch 0 taken 12325 times.
✓ Branch 1 taken 4526 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4526 times.
✓ Branch 4 taken 4526 times.
✗ Branch 5 not taken.
16851 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
19112
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4526 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4526 times.
✓ Branch 4 taken 4526 times.
✗ Branch 5 not taken.
4526 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
19113
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4526 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4526 times.
✓ Branch 4 taken 4526 times.
✗ Branch 5 not taken.
16851 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
19114 //This checks if Hero is currently swimming in solid water (cause even if the QR "No Hopping" is enabled, he should still hop out of solid water) - Dimi
19115
19116
19117
5/6
✓ Branch 0 taken 6945 times.
✓ Branch 1 taken 9906 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6945 times.
✓ Branch 4 taken 9438 times.
✓ Branch 5 taken 26275 times.
26757 if(landswim>= (get_bit(quest_rules,qr_DROWN) && isSwimming() ? 1
19118
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 9398 times.
9906 : (!diagonalMovement) ? 1 : (get_bit(quest_rules,qr_NO_HOPPING)?1:22)))
19119 {
19120 //Check for out of bounds for swimming
19121 9438 bool changehop = true;
19122
19123
5/6
✓ Branch 0 taken 905 times.
✓ Branch 1 taken 8533 times.
✓ Branch 2 taken 905 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8526 times.
✓ Branch 5 taken 7621 times.
9438 if((diagonalMovement||NO_GRIDLOCK))
19124 {
19125
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
17059 if(wx<0||wy<0)
19126 changehop = false;
19127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 else if(wx>248)
19128 changehop = false;
19129
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 else if(wx>240&&cnt==2)
19130 changehop = false;
19131
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 else if(wy>168)
19132 changehop = false;
19133 7 }
19134
3/4
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 6716 times.
✓ Branch 2 taken 7628 times.
✗ Branch 3 not taken.
7628 if ((get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) changehop = false;
19135 //This may be where the hang-up for exiting water exists. -Z
19136 // hop out of the water
19137
2/2
✓ Branch 0 taken 6716 times.
✓ Branch 1 taken 912 times.
7628 if(changehop)
19138 912 ret.setHopClk(1);
19139 7628 }
19140 else
19141 {
19142
6/6
✓ Branch 0 taken 11799 times.
✓ Branch 1 taken 14476 times.
✓ Branch 2 taken 13902 times.
✓ Branch 3 taken 12373 times.
✓ Branch 4 taken 8268 times.
✓ Branch 5 taken 5634 times.
26275 if((!(get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) || isthissolid) && (dir==d2 || shiftdir==d2))
19143 {
19144 //int32_t vx=((int32_t)x+4)&0xFFF8;
19145 //int32_t vy=((int32_t)y+4)&0xFFF8;
19146
2/2
✓ Branch 0 taken 551 times.
✓ Branch 1 taken 3015 times.
13902 if(d2==left)
19147 {
19148
4/4
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 83 times.
✓ Branch 2 taken 468 times.
✓ Branch 3 taken 83 times.
1019 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?6:11)), currmap, currscr, -1, x-1,y+(bigHitbox?6:11)) &&
19149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 468 times.
468 !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?9:12)), currmap, currscr, -1, x-1,y+(bigHitbox?9:12)) &&
19150
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 468 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 468 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 468 times.
468 !_walkflag(x-1,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
19151
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 468 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 468 times.
468 !_walkflag(x-1,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
19152 {
19153 468 ret.setHopDir(d2);
19154 468 ret.setIlswim(true);
19155 468 }
19156 83 else ret.setIlswim(false);
19157 551 }
19158
2/2
✓ Branch 0 taken 2200 times.
✓ Branch 1 taken 815 times.
3015 else if(d2==right)
19159 {
19160
4/4
✓ Branch 0 taken 602 times.
✓ Branch 1 taken 1598 times.
✓ Branch 2 taken 602 times.
✓ Branch 3 taken 1598 times.
2802 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?6:11)), currmap, currscr, -1, x+16,y+(bigHitbox?6:11)) &&
19161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 602 times.
602 !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?9:12)), currmap, currscr, -1, x+16,y+(bigHitbox?9:12)) &&
19162
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 602 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 602 times.
602 !_walkflag(x+16,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
19163
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 602 times.
602 !_walkflag(x+16,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
19164 {
19165 602 ret.setHopDir(d2);
19166 602 ret.setIlswim(true);
19167 602 }
19168 1598 else ret.setIlswim(false);
19169 2200 }
19170
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 349 times.
815 else if(d2==up)
19171 {
19172
4/4
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 91 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 93 times.
607 if(!iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1) &&
19173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 258 times.
258 !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1) &&
19174
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 258 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 258 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 256 times.
258 !_walkflag(x+7,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
19175
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
256 !_walkflag(x+8,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
19176 {
19177 256 ret.setHopDir(d2);
19178 256 ret.setIlswim(true);
19179 256 }
19180 93 else ret.setIlswim(false);
19181 349 }
19182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 else if(d2==down)
19183 {
19184
4/4
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 270 times.
✓ Branch 2 taken 196 times.
✓ Branch 3 taken 270 times.
662 if(!iswaterex(MAPCOMBO(x+7,y+16), currmap, currscr, -1, x+7,y+16) &&
19185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16) &&
19186
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 196 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 196 times.
196 !_walkflag(x+7,y+16,1,SWITCHBLOCK_STATE) &&
19187
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 196 times.
196 !_walkflag(x+8,y+16,1,SWITCHBLOCK_STATE))
19188 {
19189 196 ret.setHopDir(d2);
19190 196 ret.setIlswim(true);
19191 196 }
19192 270 else ret.setIlswim(false);
19193 466 }
19194 3566 }
19195
19196
2/4
✓ Branch 0 taken 15939 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15939 times.
15939 if(wx<0||wy<0);
19197
2/2
✓ Branch 0 taken 2246 times.
✓ Branch 1 taken 13693 times.
15939 else if(wx>248);
19198
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13693 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13693 else if(wx>240&&cnt==2);
19199
2/2
✓ Branch 0 taken 341 times.
✓ Branch 1 taken 13352 times.
13693 else if(wy>168);
19200
3/4
✓ Branch 0 taken 6106 times.
✓ Branch 1 taken 7246 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6106 times.
13352 else if(get_bit(quest_rules, qr_DROWN) && !ilswim);
19201 //if(iswaterex(MAPCOMBO(wx,wy)) && iswaterex(MAPCOMBO(wx,wy)))
19202
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 7228 times.
7246 else if(iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
19203 {
19204 18 ret.setUnwalkable(false);
19205 18 return ret;
19206 }
19207 else
19208 {
19209 7228 ret.setUnwalkable(true);
19210 7228 return ret;
19211 }
19212 }
19213 16321 }
19214 else
19215 {
19216 325082 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
19217 325082 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Is x + 8 intentional???
19218
19219
8/8
✓ Branch 0 taken 300985 times.
✓ Branch 1 taken 24097 times.
✓ Branch 2 taken 270393 times.
✓ Branch 3 taken 30592 times.
✓ Branch 4 taken 24097 times.
✓ Branch 5 taken 30592 times.
✓ Branch 6 taken 17008 times.
✓ Branch 7 taken 7089 times.
325082 if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
19220 {
19221 287401 ret.setUnwalkable(false);
19222 287401 return ret;
19223 }
19224 }
19225 54002 }
19226
2/2
✓ Branch 0 taken 255754 times.
✓ Branch 1 taken 14858696 times.
15114450 else if(ladderx+laddery) // ladder is being used
19227 {
19228
7/10
✓ Branch 0 taken 6010 times.
✓ Branch 1 taken 249744 times.
✓ Branch 2 taken 5957 times.
✓ Branch 3 taken 53 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 53 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 53 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 53 times.
255754 int32_t lx = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wx) : x;
19229
7/10
✓ Branch 0 taken 6010 times.
✓ Branch 1 taken 249744 times.
✓ Branch 2 taken 5957 times.
✓ Branch 3 taken 53 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 53 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 53 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 53 times.
255754 int32_t ly = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wy) : y;
19230
19231
4/6
✓ Branch 0 taken 255605 times.
✓ Branch 1 taken 149 times.
✓ Branch 2 taken 255605 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 255605 times.
255754 if((diagonalMovement||NO_GRIDLOCK))
19232 {
19233
1/2
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
149 if(ladderdir==up)
19234 {
19235 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
19236 {
19237 bool temp = false;
19238
19239 if(!(abs(lx-(ladderx+8))<=8))
19240 temp = true;
19241
19242 if(cnt==2)
19243 if(!(abs((lx+8)-(ladderx+8))<=8))
19244 temp=true;
19245
19246 if(!temp)
19247 {
19248 ret.setUnwalkable(false);
19249 return ret;
19250 }
19251
19252 if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
19253 {
19254 ret.setUnwalkable(true);
19255 return ret;
19256 }
19257 }
19258 }
19259 else
19260 {
19261
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 71 times.
149 if(abs(lx-(ladderx+8))<=8)
19262 {
19263
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 49 times.
71 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
19264 {
19265 22 ret.setUnwalkable(false);
19266 22 return ret;
19267 }
19268
19269
5/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
49 if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
19270 {
19271 13 ret.setUnwalkable(true);
19272 13 return ret;
19273 }
19274
19275
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
36 if((abs(ly-laddery+8)<=8) && d2<=down)
19276 {
19277 ret.setUnwalkable(false);
19278 return ret;
19279 }
19280 36 }
19281 }
19282 114 } // diagonalMovement
19283 else
19284 {
19285
2/2
✓ Branch 0 taken 152207 times.
✓ Branch 1 taken 103398 times.
255605 if((d2&2)==ladderdir) // same direction
19286 {
19287
3/3
✓ Branch 0 taken 8984 times.
✓ Branch 1 taken 135045 times.
✓ Branch 2 taken 8178 times.
152207 switch(d2)
19288 {
19289 case up:
19290
2/2
✓ Branch 0 taken 5684 times.
✓ Branch 1 taken 2494 times.
8178 if(y.getInt()<=laddery)
19291 {
19292
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5684 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5684 times.
✓ Branch 4 taken 432 times.
✓ Branch 5 taken 5252 times.
10936 ret.setUnwalkable(_walkflag(ladderx,laddery-8,1,SWITCHBLOCK_STATE) ||
19293
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5252 times.
✓ Branch 2 taken 5252 times.
✗ Branch 3 not taken.
5252 _walkflag(ladderx+8,laddery-8,1,SWITCHBLOCK_STATE));
19294 5684 return ret;
19295
19296 }
19297
19298 [[fallthrough]];
19299 case down:
19300
2/2
✓ Branch 0 taken 6138 times.
✓ Branch 1 taken 5340 times.
11478 if((wy&0xF0)==laddery)
19301 {
19302 6138 ret.setUnwalkable(false);
19303 6138 return ret;
19304 }
19305
19306 5340 break;
19307
19308 default:
19309
2/2
✓ Branch 0 taken 53843 times.
✓ Branch 1 taken 81202 times.
135045 if((wx&0xF0)==ladderx)
19310 {
19311 53843 ret.setUnwalkable(false);
19312 53843 return ret;
19313 }
19314 81202 }
19315
19316
2/2
✓ Branch 0 taken 5340 times.
✓ Branch 1 taken 81202 times.
86542 if(d2<=down)
19317 {
19318
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 5340 times.
✓ Branch 2 taken 5340 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 593 times.
✓ Branch 5 taken 4747 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4747 times.
✓ Branch 8 taken 4747 times.
✗ Branch 9 not taken.
5340 ret.setUnwalkable(_walkflag(ladderx,wy,1,SWITCHBLOCK_STATE) || _walkflag(ladderx+8,wy,1,SWITCHBLOCK_STATE));
19319 5340 return ret;
19320 }
19321
19322
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 81202 times.
✓ Branch 2 taken 81202 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14606 times.
✓ Branch 5 taken 66596 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 66596 times.
✓ Branch 8 taken 66596 times.
✗ Branch 9 not taken.
81202 ret.setUnwalkable(_walkflag((wx&0xF0),wy,1,SWITCHBLOCK_STATE) || _walkflag((wx&0xF0)+8,wy,1,SWITCHBLOCK_STATE));
19323 81202 return ret;
19324 }
19325
19326 // different dir
19327
3/8
✓ Branch 0 taken 102969 times.
✓ Branch 1 taken 429 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102969 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
103398 if(current_item_power(itype_ladder)<2 && !(isSideViewHero() && (d2==left || d2==right)))
19328 {
19329 102969 ret.setUnwalkable(true);
19330 102969 return ret;
19331 }
19332
19333
5/6
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 372 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 352 times.
✓ Branch 5 taken 20 times.
429 if(wy>=laddery && wy<=laddery+16 && d2<=down)
19334 {
19335 20 ret.setUnwalkable(false);
19336 20 return ret;
19337 }
19338 }
19339 523 }
19340
6/6
✓ Branch 0 taken 12289188 times.
✓ Branch 1 taken 2569508 times.
✓ Branch 2 taken 11986443 times.
✓ Branch 3 taken 302745 times.
✓ Branch 4 taken 1446109 times.
✓ Branch 5 taken 10540334 times.
14858696 else if(wf || isSideViewHero() || get_bit(quest_rules, qr_DROWN))
19341 {
19342 // see if it's a good spot for the ladder or for swimming
19343
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4318362 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4318362 times.
4318362 bool unwalkablex = _walkflag(wx,wy,1,SWITCHBLOCK_STATE); //will be used later for the ladder -DD
19344
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4318362 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4318362 times.
4318362 bool unwalkablex8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE);
19345
19346
2/2
✓ Branch 0 taken 2266303 times.
✓ Branch 1 taken 2052059 times.
4318362 if(get_bit(quest_rules, qr_DROWN))
19347 {
19348 // Drowning changes the following attributes:
19349 // * Dangerous water is also walkable, so ignore the previous
19350 // definitions of unwalkablex and unwalkablex8.
19351 // * Instead, prevent the ladder from being used in the
19352 // one frame where Hero has landed on water before drowning.
19353 2266303 unwalkablex = unwalkablex8 = !iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11);
19354 2266303 }
19355
19356 // check if he can swim
19357
5/6
✓ Branch 0 taken 1330235 times.
✓ Branch 1 taken 2988127 times.
✓ Branch 2 taken 1330019 times.
✓ Branch 3 taken 216 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1330019 times.
4318362 if(current_item(itype_flippers) && z==0 && fakez==0)
19358 {
19359 1330019 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
19360 1330019 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Still not sure if this should be x + 8...
19361
2/6
✓ Branch 0 taken 1330019 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1330019 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1330019 if (current_item(itype_flippers) >= combobuf[wtrx8].attribytes[0] && (!(combobuf[wtrx8].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))) //Don't swim if the water's required level is too high! -Dimi
19362 {
19363 //ladder ignores water combos that are now walkable thanks to flippers -DD
19364
2/2
✓ Branch 0 taken 5037 times.
✓ Branch 1 taken 1324982 times.
1330019 unwalkablex = unwalkablex && (!wtrx);
19365
2/2
✓ Branch 0 taken 574392 times.
✓ Branch 1 taken 755627 times.
1330019 unwalkablex8 = unwalkablex8 && (!wtrx8);
19366
19367
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1330015 times.
1330019 if(landswim >= 22)
19368 {
19369 4 ret.setHopClk(2);
19370 4 ret.setUnwalkable(false);
19371 4 return ret;
19372 }
19373
8/8
✓ Branch 0 taken 1173940 times.
✓ Branch 1 taken 156075 times.
✓ Branch 2 taken 6535 times.
✓ Branch 3 taken 1167405 times.
✓ Branch 4 taken 156075 times.
✓ Branch 5 taken 1167405 times.
✓ Branch 6 taken 873 times.
✓ Branch 7 taken 155202 times.
1330015 else if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
19374 {
19375
4/6
✓ Branch 0 taken 5986 times.
✓ Branch 1 taken 1422 times.
✓ Branch 2 taken 5986 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5986 times.
7408 if(!(diagonalMovement||NO_GRIDLOCK))
19376 {
19377 5986 ret.setHopClk(2);
19378
19379
2/4
✓ Branch 0 taken 5986 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5986 times.
5986 if(charging || spins>5)
19380 {
19381 //if Hero is charging, he might be facing the wrong direction (we want him to
19382 //hop into the water, not in the facing direction)
19383 ret.setDir(d2);
19384 //moreover Hero can't charge in the water -DD
19385 ret.setChargeAttack();
19386 }
19387
19388 5986 ret.setUnwalkable(false);
19389 5986 return ret;
19390 }
19391
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 1245 times.
1422 else if(dir==d2)
19392 {
19393 1245 ret.setIlswim(true);
19394 1245 ladderx = 0;
19395 1245 laddery = 0;
19396 1245 }
19397 1422 }
19398 1324029 }
19399 1324029 }
19400
19401 // check if he can use the ladder
19402 // "Allow Ladder Anywhere" is toggled by fLADDER
19403
2/2
✓ Branch 0 taken 2983376 times.
✓ Branch 1 taken 1328996 times.
4312372 if(can_deploy_ladder())
19404 // laddersetup
19405 {
19406 // Check if there's water to use the ladder over
19407 1328996 bool wtrx = (iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy) != 0);
19408 1328996 bool wtrx8 = (iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy) != 0);
19409 1328996 int32_t ldrid = current_item_id(itype_ladder);
19410
1/2
✓ Branch 0 taken 1328996 times.
✗ Branch 1 not taken.
1328996 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&ITEM_FLAG1);
19411
19412
4/4
✓ Branch 0 taken 1321505 times.
✓ Branch 1 taken 7491 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 1321485 times.
1328996 if(wtrx || wtrx8)
19413 {
19414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7511 times.
7511 if(isSideViewHero())
19415 {
19416 wtrx = !_walkflag(wx, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
19417 wtrx8 = !_walkflag(wx+8, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx+8, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
19418 }
19419 // * walk on half-water using the ladder instead of using flippers.
19420 // * otherwise, walk on ladder(+hookshot) combos.
19421
3/8
✓ Branch 0 taken 426 times.
✓ Branch 1 taken 7085 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 426 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7511 else if(wtrx==wtrx8 && (isstepable(MAPCOMBO(wx, wy)) || isstepable(MAPCOMBO(wx+8,wy)) || wtrx==true))
19422 {
19423
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 387 times.
426 if(!get_bit(quest_rules, qr_OLD_210_WATER))
19424 {
19425 //if Hero could swim on a tile instead of using the ladder,
19426 //refuse to use the ladder to step over that tile. -DD
19427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 wtrx = isstepable(MAPCOMBO(wx, wy)) && unwalkablex;
19428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 wtrx8 = isstepable(MAPCOMBO(wx+8,wy)) && unwalkablex8;
19429 387 }
19430 426 }
19431 7511 }
19432 else
19433 {
19434 // No water; check other things
19435
19436 //Check pits
19437
2/2
✓ Branch 0 taken 1320458 times.
✓ Branch 1 taken 1027 times.
1321485 if(ladderpits)
19438 {
19439 1027 int32_t pit_cmb = getpitfall(wx,wy);
19440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
19441 1027 pit_cmb = getpitfall(x+8,wy);
19442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 wtrx8 = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
19443 1027 }
19444
4/6
✓ Branch 0 taken 1027 times.
✓ Branch 1 taken 1320458 times.
✓ Branch 2 taken 1027 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1027 times.
✗ Branch 5 not taken.
1321485 if(!ladderpits || (!(wtrx || wtrx8) || isSideViewHero())) //If no pit, check ladder combos
19445 {
19446 1321485 int32_t combo=combobuf[MAPCOMBO(wx, wy)].type;
19447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1321485 times.
1321485 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
19448 1321485 combo=combobuf[MAPCOMBO(wx+8, wy)].type;
19449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1321485 times.
1321485 wtrx8=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
19450 1321485 }
19451 }
19452
19453
2/2
✓ Branch 0 taken 2657992 times.
✓ Branch 1 taken 1328996 times.
3986988 for (int32_t i = 0; i <= 1; ++i)
19454 {
19455
2/2
✓ Branch 0 taken 2273662 times.
✓ Branch 1 taken 384330 times.
2657992 if(tmpscr2[i].valid!=0)
19456 {
19457
2/2
✓ Branch 0 taken 319092 times.
✓ Branch 1 taken 65238 times.
384330 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19458 {
19459
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 319092 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
319092 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && !_walkflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
19460
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 319092 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
319092 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && !_walkflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
19461 319092 }
19462 else
19463 {
19464
3/4
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 64979 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 259 times.
65238 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && _effectflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
19465
3/4
✓ Branch 0 taken 237 times.
✓ Branch 1 taken 65001 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 237 times.
65238 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && _effectflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
19466 }
19467 384330 }
19468 2657992 }
19469
2/2
✓ Branch 0 taken 180430 times.
✓ Branch 1 taken 1148566 times.
1328996 bool walkwater = (get_bit(quest_rules, qr_DROWN) && !iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy));
19470
19471
4/6
✓ Branch 0 taken 1288526 times.
✓ Branch 1 taken 40470 times.
✓ Branch 2 taken 1288526 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1288526 times.
1328996 if((diagonalMovement||NO_GRIDLOCK))
19472 {
19473
2/2
✓ Branch 0 taken 11725 times.
✓ Branch 1 taken 28745 times.
40470 if(d2==dir)
19474 {
19475 28745 int32_t c = walkwater ? 0:8;
19476 28745 int32_t b = walkwater ? 8:0;
19477
19478
2/2
✓ Branch 0 taken 21217 times.
✓ Branch 1 taken 7528 times.
28745 if(d2>=left)
19479 {
19480 // If the difference between wy and y is small enough
19481
4/4
✓ Branch 0 taken 6210 times.
✓ Branch 1 taken 15007 times.
✓ Branch 2 taken 21214 times.
✓ Branch 3 taken 3 times.
21217 if(abs((wy)-(int32_t(y+c)))<=(b) && wtrx)
19482 {
19483 // Don't activate the ladder if it would be entirely
19484 // over water and Hero has the flippers. This isn't
19485 // a good way to do this, but it's too risky
19486 // to make big changes to this stuff.
19487 3 bool deployLadder=true;
19488 3 int32_t lx=wx&0xF0;
19489
6/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 2 times.
3 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex(MAPCOMBO(lx+8, y+8), currmap, currscr, -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
19490 {
19491
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(iswaterex(MAPCOMBO(lx, y), currmap, currscr, -1, lx, y) &&
19492 iswaterex(MAPCOMBO(lx+15, y), currmap, currscr, -1, lx+15, y) &&
19493 iswaterex(MAPCOMBO(lx, y+15), currmap, currscr, -1, lx, y+15) &&
19494 iswaterex(MAPCOMBO(lx+15, y+15), currmap, currscr, -1, lx+15, y+15))
19495 deployLadder=false;
19496 2 }
19497
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(deployLadder)
19498 {
19499 3 ladderx = wx&0xF0;
19500 3 laddery = y;
19501 3 ladderdir = left;
19502 3 ladderstart = d2;
19503 3 ret.setUnwalkable(laddery!=y.getInt());
19504 3 return ret;
19505 }
19506 }
19507 21214 }
19508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7528 times.
7528 else if(d2<=down)
19509 {
19510 // If the difference between wx and x is small enough
19511
3/4
✓ Branch 0 taken 2823 times.
✓ Branch 1 taken 4705 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7528 times.
7528 if(abs((wx)-(int32_t(x+c)))<=(b) && wtrx)
19512 {
19513 ladderx = x;
19514 laddery = wy&0xF0;
19515 ladderdir = up;
19516 ladderstart = d2;
19517 ret.setUnwalkable(ladderx!=x.getInt());
19518 return ret;
19519 }
19520
19521
2/2
✓ Branch 0 taken 2823 times.
✓ Branch 1 taken 4705 times.
7528 if(cnt==2)
19522 {
19523
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4705 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4705 times.
4705 if(abs((wx+8)-(int32_t(x+c)))<=(b) && wtrx8)
19524 {
19525 ladderx = x;
19526 laddery = wy&0xF0;
19527 ladderdir = up;
19528 ladderstart = d2;
19529 ret.setUnwalkable(ladderx!=x.getInt());
19530 return ret;
19531 }
19532 4705 }
19533 7528 }
19534 28742 }
19535 40467 }
19536 else
19537 {
19538
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1288526 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1288526 times.
✓ Branch 4 taken 110191 times.
✓ Branch 5 taken 1178335 times.
1288526 bool flgx = _walkflag(wx,wy,1,SWITCHBLOCK_STATE) && !wtrx; // Solid, and not steppable
19539
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1288526 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1288526 times.
✓ Branch 4 taken 1205515 times.
✓ Branch 5 taken 83011 times.
1288526 bool flgx8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE) && !wtrx8; // Solid, and not steppable
19540
19541
2/2
✓ Branch 0 taken 1188054 times.
✓ Branch 1 taken 100472 times.
1288562 if((d2>=left && wtrx)
19542 // Deploy the ladder vertically even if Hero is only half on water.
19543
8/8
✓ Branch 0 taken 12556 times.
✓ Branch 1 taken 1175498 times.
✓ Branch 2 taken 100472 times.
✓ Branch 3 taken 1175498 times.
✓ Branch 4 taken 822 times.
✓ Branch 5 taken 99650 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 100436 times.
1288526 || (d2<=down && ((wtrx && !flgx8) || (wtrx8 && !flgx))))
19544 {
19545
4/4
✓ Branch 0 taken 12202 times.
✓ Branch 1 taken 354 times.
✓ Branch 2 taken 501 times.
✓ Branch 3 taken 11701 times.
12556 if(((y.getInt()+15) < wy) || ((y.getInt()+8) > wy))
19546 855 ladderdir = up;
19547 else
19548 11701 ladderdir = left;
19549
19550
2/2
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 11701 times.
12556 if(ladderdir==up)
19551 {
19552 855 ladderx = x.getInt()&0xF8;
19553 855 laddery = wy&0xF0;
19554 855 }
19555 else
19556 {
19557 11701 ladderx = wx&0xF0;
19558 11701 laddery = y.getInt()&0xF8;
19559 }
19560
19561 12556 ret.setUnwalkable(false);
19562 12556 return ret;
19563 }
19564 }
19565 1316437 }
19566 4299813 }
19567
19568 14894672 ret.setUnwalkable(wf);
19569 14894672 return ret;
19570 15702651 }
19571
19572 // Only checks for moving blocks. Apparently this is a thing we need.
19573 1484051 HeroClass::WalkflagInfo HeroClass::walkflagMBlock(int32_t wx,int32_t wy)
19574 {
19575 1484051 HeroClass::WalkflagInfo ret;
19576
2/2
✓ Branch 0 taken 15089 times.
✓ Branch 1 taken 1468962 times.
1484051 if (!blockmoving) //Without this, weird swimming behaviors happen.
19577 {
19578 1468962 ret.setFlags(~1);
19579 1468962 ret.setHopDir(-1);
19580 1468962 }
19581
2/2
✓ Branch 0 taken 2636 times.
✓ Branch 1 taken 1481415 times.
1484051 if(toogam) return ret;
19582
2/2
✓ Branch 0 taken 1466326 times.
✓ Branch 1 taken 15089 times.
1481415 if (blockmoving)
19583 15089 ret.setUnwalkable(mblock2.hit(wx,wy,0,1,1,1));
19584
1/2
✓ Branch 0 taken 1481415 times.
✗ Branch 1 not taken.
1481415 if (collide_object(wx, wy,1, 1))
19585 ret.setUnwalkable(true);
19586 1481415 return ret;
19587 1484051 }
19588
19589 6264576 bool HeroClass::checksoliddamage()
19590 {
19591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6264576 times.
6264576 if(toogam) return false;
19592
19593
2/4
✓ Branch 0 taken 6264576 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6264576 times.
6264576 if(z!=0||fakez!=0) return false;
19594 6264576 int32_t bx = x.getInt();
19595 6264576 int32_t by = y.getInt();
19596 6264576 int32_t initk = 0;
19597
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1509948 times.
✓ Branch 2 taken 1221745 times.
✓ Branch 3 taken 1695402 times.
✓ Branch 4 taken 1837481 times.
6264576 switch(dir)
19598 {
19599 case up:
19600
19601 1509948 by-=bigHitbox ? 4 : -4;
19602
19603
2/2
✓ Branch 0 taken 1509896 times.
✓ Branch 1 taken 52 times.
1509948 if(by<0)
19604 {
19605 52 return false;
19606 }
19607 1509896 break;
19608
19609 case down:
19610
19611 1221745 by+=20;
19612
2/2
✓ Branch 0 taken 11062 times.
✓ Branch 1 taken 1210683 times.
1221745 if(by>175)
19613 {
19614 11062 return false;
19615 }
19616
19617 1210683 break;
19618
19619 case left:
19620 1695402 bx-=4;
19621
2/2
✓ Branch 0 taken 9483 times.
✓ Branch 1 taken 1685919 times.
1695402 if (!bigHitbox)
19622 {
19623 1685919 by+=8;
19624 1685919 initk = 1;
19625 1685919 }
19626
2/2
✓ Branch 0 taken 1686581 times.
✓ Branch 1 taken 8821 times.
1695402 if(bx<0)
19627 {
19628 8821 return false;
19629 }
19630
19631 1686581 break;
19632
19633 case right:
19634
19635 1837481 bx+=20;
19636
2/2
✓ Branch 0 taken 13038 times.
✓ Branch 1 taken 1824443 times.
1837481 if (!bigHitbox)
19637 {
19638 1824443 by+=8;
19639 1824443 initk = 1;
19640 1824443 }
19641
2/2
✓ Branch 0 taken 13098 times.
✓ Branch 1 taken 1824383 times.
1837481 if(bx>255)
19642 {
19643 13098 return false;
19644 }
19645
19646 1824383 break;
19647 }
19648 6231543 newcombo const& cmb = combobuf[MAPCOMBO(bx,by)];
19649 6231543 int32_t t = cmb.type;
19650
2/2
✓ Branch 0 taken 6231427 times.
✓ Branch 1 taken 116 times.
6231543 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
19651 116 t = cNONE;
19652 6231543 int32_t initbx = bx;
19653 6231543 int32_t initby = by;
19654
19655 // Unlike push blocks, damage combos should be tested on layers 2 and under
19656
2/2
✓ Branch 0 taken 10261417 times.
✓ Branch 1 taken 6231527 times.
16492944 for(int32_t i=(get_bit(quest_rules,qr_DMGCOMBOLAYERFIX) ? 2 : 0); i>=0; i--)
19657 {
19658 10261417 bx = initbx;
19659 10261417 by = initby;
19660
2/2
✓ Branch 0 taken 24998953 times.
✓ Branch 1 taken 10261401 times.
35260354 for (int32_t k = initk; k <= 2; k++)
19661 {
19662 24998953 newcombo const& cmb = combobuf[FFCore.tempScreens[i]->data[COMBOPOS(bx,by)]];
19663 24998953 t = cmb.type;
19664
2/2
✓ Branch 0 taken 24998627 times.
✓ Branch 1 taken 326 times.
24998953 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
19665 326 t = cNONE;
19666 // Solid damage combos use pushing>0, hence the code is here.
19667
10/10
✓ Branch 0 taken 377707 times.
✓ Branch 1 taken 24621246 times.
✓ Branch 2 taken 115489 times.
✓ Branch 3 taken 262218 times.
✓ Branch 4 taken 101377 times.
✓ Branch 5 taken 14112 times.
✓ Branch 6 taken 2880 times.
✓ Branch 7 taken 98497 times.
✓ Branch 8 taken 45 times.
✓ Branch 9 taken 2835 times.
24998953 if (!get_bit(quest_rules, qr_LESS_AWFUL_SIDESPIKES) || !isSideViewHero() || (dir != down && (dir != up || getOnSideviewLadder())))
19668 {
19669
14/18
✓ Branch 0 taken 24970915 times.
✓ Branch 1 taken 11091 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11091 times.
✓ Branch 4 taken 11091 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1294 times.
✓ Branch 7 taken 9797 times.
✓ Branch 8 taken 253 times.
✓ Branch 9 taken 1041 times.
✓ Branch 10 taken 160 times.
✓ Branch 11 taken 93 times.
✓ Branch 12 taken 160 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 160 times.
✓ Branch 16 taken 24981946 times.
✓ Branch 17 taken 60 times.
24982006 if(combo_class_buf[t].modify_hp_amount && _walkflag(bx,by,1,SWITCHBLOCK_STATE) && pushing>0 && hclk<1 && action!=casting && action != sideswimcasting && !get_bit(quest_rules, qr_NOSOLIDDAMAGECOMBOS))
19670 {
19671 // Bite Hero
19672
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 6 times.
60 if (checkdamagecombos(bx, bx, by, by, i-1, true)) return true;
19673 54 }
19674 24982000 }
19675
3/4
✓ Branch 0 taken 842465 times.
✓ Branch 1 taken 24156482 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 780689 times.
25779636 if(isSideViewHero() && // Check for sideview damage combos
19676
3/4
✓ Branch 0 taken 780689 times.
✓ Branch 1 taken 61776 times.
✓ Branch 2 taken 780689 times.
✗ Branch 3 not taken.
842465 hclk<1 && action!=casting && action!=sideswimcasting) // ... but only if Hero could be hurt
19677 {
19678
2/2
✓ Branch 0 taken 110215 times.
✓ Branch 1 taken 670474 times.
780689 if (get_bit(quest_rules, qr_LESS_AWFUL_SIDESPIKES))
19679 {
19680
4/6
✓ Branch 0 taken 110215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 110170 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 45 times.
110215 if (on_sideview_solid_oldpos(x,y,old_x,old_y) && (!getOnSideviewLadder() || DrunkDown()))
19681 {
19682
4/4
✓ Branch 0 taken 110161 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 110165 times.
✓ Branch 3 taken 5 times.
110170 if(checkdamagecombos(x+4, x+4, y+16, y+18, i-1, false, false) && checkdamagecombos(x+12, x+12, y+16, y+18, i-1, false, false))
19683 {
19684
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (checkdamagecombos(x+4, x+12, y+16, y+18, i-1, false, true)) return true;
19685 }
19686 110165 }
19687
1/2
✓ Branch 0 taken 110210 times.
✗ Branch 1 not taken.
110210 if (checkdamagecombos(x+4, x+12, y+8, y+15, i-1, false, true)) return true;
19688 110210 }
19689 else
19690 {
19691 //old 2.50.2-ish code for 2.50.0 sideview quests for er_OLDSIDEVIEWSPIKES
19692
1/2
✓ Branch 0 taken 670474 times.
✗ Branch 1 not taken.
670474 if ( get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES ) )
19693 {
19694
2/2
✓ Branch 0 taken 670469 times.
✓ Branch 1 taken 5 times.
1340948 if (checkdamagecombos(x+8-(zfix)(tmpscr->csensitive),
19695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 670474 times.
670474 x+8+(zc_max(tmpscr->csensitive-1,0)),
19696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 670474 times.
670474 y+17-(get_bit(quest_rules,qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2),
19697
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 670474 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 670474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
670474 y+17+zc_max((get_bit(quest_rules,qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2)-1,0), i-1, true))
19698 5 return true;
19699 670469 }
19700 else //2.50.1 and later
19701 {
19702 if(checkdamagecombos(x+4, x+12, y+16, y+24))
19703 return true;
19704 }
19705 }
19706
19707 780679 }
19708
2/2
✓ Branch 0 taken 13227138 times.
✓ Branch 1 taken 11771799 times.
24998937 if (dir < left) bx += (k % 2) ? 7 : 8;
19709 11771799 else by += (k % 2) ? 7 : 8;
19710 24998937 }
19711 10261401 }
19712 6231527 return false;
19713 6264576 }
19714 6409244 void HeroClass::checkpushblock()
19715 {
19716
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 6395838 times.
6409244 if(toogam) return;
19717
19718
3/4
✓ Branch 0 taken 6392205 times.
✓ Branch 1 taken 3633 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6392205 times.
6395838 if(z!=0||fakez!=0) return;
19719
19720 // Return early in some cases..
19721 6392205 bool earlyReturn=false;
19722
19723
5/6
✓ Branch 0 taken 5684070 times.
✓ Branch 1 taken 708135 times.
✓ Branch 2 taken 5684070 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5917429 times.
✓ Branch 5 taken 474776 times.
6392205 if(!(diagonalMovement||NO_GRIDLOCK) || dir==left)
19724
2/2
✓ Branch 0 taken 2221378 times.
✓ Branch 1 taken 3696051 times.
5917429 if(x.getInt()&15) earlyReturn=true;
19725
19726 // if(y<16) return;
19727
4/4
✓ Branch 0 taken 261476 times.
✓ Branch 1 taken 6130729 times.
✓ Branch 2 taken 133847 times.
✓ Branch 3 taken 127629 times.
6392205 if(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y)) return;
19728
19729 6264576 int32_t bx = x.getInt()&0xF0;
19730 6264576 int32_t by = (y.getInt()&0xF0);
19731
19732
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1509948 times.
✓ Branch 2 taken 1221745 times.
✓ Branch 3 taken 1695402 times.
✓ Branch 4 taken 1837481 times.
6264576 switch(dir)
19733 {
19734 case up:
19735
2/2
✓ Branch 0 taken 50377 times.
✓ Branch 1 taken 1459571 times.
1509948 if(y<16)
19736 {
19737 50377 earlyReturn=true;
19738 50377 break;
19739 }
19740
19741
3/4
✓ Branch 0 taken 267262 times.
✓ Branch 1 taken 1192309 times.
✓ Branch 2 taken 267262 times.
✗ Branch 3 not taken.
1459571 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
19742
19743
2/2
✓ Branch 0 taken 834170 times.
✓ Branch 1 taken 625401 times.
1459571 if((int32_t)x&8) bx+=16;
19744
19745 1459571 break;
19746
19747 case down:
19748
2/2
✓ Branch 0 taken 80721 times.
✓ Branch 1 taken 1141024 times.
1221745 if(y>128)
19749 {
19750 80721 earlyReturn=true;
19751 80721 break;
19752 }
19753 else
19754 {
19755 1141024 by+=16;
19756
19757
2/2
✓ Branch 0 taken 720192 times.
✓ Branch 1 taken 420832 times.
1141024 if((int32_t)x&8) bx+=16;
19758 }
19759
19760 1141024 break;
19761
19762 case left:
19763
2/2
✓ Branch 0 taken 84925 times.
✓ Branch 1 taken 1610477 times.
1695402 if(x<32)
19764 {
19765 84925 earlyReturn=true;
19766 84925 break;
19767 }
19768 else
19769 {
19770 1610477 bx-=16;
19771
19772
2/2
✓ Branch 0 taken 1029268 times.
✓ Branch 1 taken 581209 times.
1610477 if(y.getInt()&8)
19773 {
19774 581209 by+=16;
19775 581209 }
19776 }
19777
19778 1610477 break;
19779
19780 case right:
19781
2/2
✓ Branch 0 taken 88701 times.
✓ Branch 1 taken 1748780 times.
1837481 if(x>208)
19782 {
19783 88701 earlyReturn=true;
19784 88701 break;
19785 }
19786 else
19787 {
19788 1748780 bx+=16;
19789
19790
2/2
✓ Branch 0 taken 1136847 times.
✓ Branch 1 taken 611933 times.
1748780 if(y.getInt()&8)
19791 {
19792 611933 by+=16;
19793 611933 }
19794 }
19795
19796 1748780 break;
19797 }
19798
19799
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 6264560 times.
6264576 if (checksoliddamage()) return;
19800
19801
2/2
✓ Branch 0 taken 3760827 times.
✓ Branch 1 taken 2503733 times.
6264560 if(earlyReturn)
19802 3760827 return;
19803
19804 2503733 int itemid=current_item_id(itype_bracelet);
19805 2503733 size_t combopos = (by&0xF0)+(bx>>4);
19806
2/2
✓ Branch 0 taken 952859 times.
✓ Branch 1 taken 1550874 times.
2503733 bool limitedpush = (itemid>=0 && itemsbuf[itemid].flags & ITEM_FLAG1);
19807
2/2
✓ Branch 0 taken 1550874 times.
✓ Branch 1 taken 952859 times.
2503733 itemdata const* glove = itemid < 0 ? NULL : &itemsbuf[itemid];
19808
2/2
✓ Branch 0 taken 1121805 times.
✓ Branch 1 taken 4764918 times.
5886723 for(int lyr = 2; lyr > -1; --lyr) //Top-down, in case of stacked push blocks
19809 {
19810
4/4
✓ Branch 0 taken 1901781 times.
✓ Branch 1 taken 2863137 times.
✓ Branch 2 taken 526175 times.
✓ Branch 3 taken 1375606 times.
4764918 if(get_bit(quest_rules,qr_HESITANTPUSHBLOCKS)&&(pushing<4)) break;
19811
4/4
✓ Branch 0 taken 2256254 times.
✓ Branch 1 taken 1133058 times.
✓ Branch 2 taken 7022 times.
✓ Branch 3 taken 2249232 times.
3389312 if(lyr && !get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
19812 2249232 continue;
19813 1140080 cpos_info& cpinfo = combo_posinfos[lyr][combopos];
19814 1140080 mapscr* m = FFCore.tempScreens[lyr];
19815
2/2
✓ Branch 0 taken 1128126 times.
✓ Branch 1 taken 11954 times.
1140080 int cid = lyr == 0 ? MAPCOMBO(bx,by) : MAPCOMBOL(lyr,bx,by);
19816 1140080 newcombo const& cmb = combobuf[cid];
19817 1140080 int f = MAPFLAG2(lyr-1,bx,by);
19818 1140080 int f2 = cmb.flag;
19819 1140080 int t = cmb.type;
19820
19821
6/6
✓ Branch 0 taken 1040088 times.
✓ Branch 1 taken 99992 times.
✓ Branch 2 taken 1037329 times.
✓ Branch 3 taken 2759 times.
✓ Branch 4 taken 2027 times.
✓ Branch 5 taken 1035302 times.
2175382 bool waitblock = (t==cPUSH_WAIT || t==cPUSH_HW || t==cPUSH_HW2) ||
19822
1/2
✓ Branch 0 taken 1035302 times.
✗ Branch 1 not taken.
1035302 (t == cPUSHBLOCK && (cmb.usrflags&cflag6));
19823 1140080 int heavy = 0;
19824
4/4
✓ Branch 0 taken 1132389 times.
✓ Branch 1 taken 7691 times.
✓ Branch 2 taken 7911 times.
✓ Branch 3 taken 1124478 times.
1140080 if(t==cPUSH_HW || t==cPUSH_HEAVY)
19825 15602 heavy = 1;
19826
4/4
✓ Branch 0 taken 1123172 times.
✓ Branch 1 taken 1306 times.
✓ Branch 2 taken 2027 times.
✓ Branch 3 taken 1121145 times.
1124478 else if(t==cPUSH_HEAVY2 || t==cPUSH_HW2)
19827 3333 heavy = 2;
19828
1/2
✓ Branch 0 taken 1121145 times.
✗ Branch 1 not taken.
1121145 else if(t == cPUSHBLOCK)
19829 heavy = cmb.attribytes[0];
19830
19831
6/6
✓ Branch 0 taken 99846 times.
✓ Branch 1 taken 1040234 times.
✓ Branch 2 taken 34028 times.
✓ Branch 3 taken 65818 times.
✓ Branch 4 taken 2753 times.
✓ Branch 5 taken 31275 times.
1140080 if(waitblock && (pushing<16 || hasMainGuy())) continue;
19832
19833
8/8
✓ Branch 0 taken 10839 times.
✓ Branch 1 taken 1060670 times.
✓ Branch 2 taken 9936 times.
✓ Branch 3 taken 903 times.
✓ Branch 4 taken 741 times.
✓ Branch 5 taken 9195 times.
✓ Branch 6 taken 1644 times.
✓ Branch 7 taken 1069865 times.
1091543 if(heavy && (itemid<0 || glove->power < heavy ||
19834
3/4
✓ Branch 0 taken 9189 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
10839 (limitedpush && usecounts[itemid] > zc_max(1, glove->misc3)))) continue;
19835
19836 1069865 bool doit=false;
19837 1069865 bool changeflag=false;
19838 1069865 bool changecombo=false;
19839
19840 1069865 int blockdir = dir;
19841
1/2
✓ Branch 0 taken 1069865 times.
✗ Branch 1 not taken.
1069865 if(blockdir > 3) blockdir = Y_DIR(dir);
19842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1069865 times.
1069865 if(t == cPUSHBLOCK)
19843 {
19844 switch(blockdir)
19845 {
19846 case up:
19847 doit = cmb.usrflags & cflag1;
19848 break;
19849 case down:
19850 doit = cmb.usrflags & cflag2;
19851 break;
19852 case left:
19853 doit = cmb.usrflags & cflag3;
19854 break;
19855 case right:
19856 doit = cmb.usrflags & cflag4;
19857 break;
19858 }
19859 if(cmb.usrflags & cflag5) //Separate directions
19860 {
19861 if(int limit = cmb.attribytes[4+blockdir])
19862 {
19863 if(cpinfo.pushes[blockdir] >= limit)
19864 doit = false;
19865 }
19866 else if(cmb.usrflags & cflag9)
19867 doit = false;
19868 }
19869 else
19870 {
19871 if(int limit = cmb.attribytes[4])
19872 {
19873 if(cpinfo.sumpush() >= limit)
19874 doit = false;
19875 }
19876 else if(cmb.usrflags & cflag9)
19877 doit = false;
19878 }
19879 }
19880 else
19881 {
19882
8/8
✓ Branch 0 taken 1064737 times.
✓ Branch 1 taken 5128 times.
✓ Branch 2 taken 1064733 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 2741 times.
✓ Branch 5 taken 1067124 times.
✓ Branch 6 taken 367 times.
✓ Branch 7 taken 1061758 times.
2131990 if(((f==mfPUSHUD || f==mfPUSHUDNS|| f==mfPUSHUDINS) && dir<=down) ||
19883
4/4
✓ Branch 0 taken 1064804 times.
✓ Branch 1 taken 2320 times.
✓ Branch 2 taken 1064802 times.
✓ Branch 3 taken 2 times.
1067124 ((f==mfPUSHLR || f==mfPUSHLRNS|| f==mfPUSHLRINS) && dir>=left) ||
19884
4/4
✓ Branch 0 taken 1064787 times.
✓ Branch 1 taken 2337 times.
✓ Branch 2 taken 1064659 times.
✓ Branch 3 taken 128 times.
1067124 ((f==mfPUSHU || f==mfPUSHUNS || f==mfPUSHUINS) && dir==up) ||
19885
3/4
✓ Branch 0 taken 1064745 times.
✓ Branch 1 taken 2379 times.
✓ Branch 2 taken 1064745 times.
✗ Branch 3 not taken.
1067124 ((f==mfPUSHD || f==mfPUSHDNS || f==mfPUSHDINS) && dir==down) ||
19886
3/4
✓ Branch 0 taken 1064647 times.
✓ Branch 1 taken 2477 times.
✓ Branch 2 taken 1064647 times.
✗ Branch 3 not taken.
1067124 ((f==mfPUSHL || f==mfPUSHLNS || f==mfPUSHLINS) && dir==left) ||
19887
3/4
✓ Branch 0 taken 1064668 times.
✓ Branch 1 taken 2456 times.
✓ Branch 2 taken 1064668 times.
✗ Branch 3 not taken.
1067124 ((f==mfPUSHR || f==mfPUSHRNS || f==mfPUSHRINS) && dir==right) ||
19888
2/2
✓ Branch 0 taken 1062125 times.
✓ Branch 1 taken 87 times.
1062212 f==mfPUSH4 || f==mfPUSH4NS || f==mfPUSH4INS)
19889 {
19890 3195 changeflag=true;
19891 3195 doit=true;
19892 3195 }
19893
19894
7/8
✓ Branch 0 taken 1064933 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 1064933 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 1064943 times.
✓ Branch 6 taken 1064932 times.
✓ Branch 7 taken 1 times.
2129876 if((((f2==mfPUSHUD || f2==mfPUSHUDNS|| f2==mfPUSHUDINS) && dir<=down) ||
19895
3/4
✓ Branch 0 taken 1064933 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1064933 times.
✗ Branch 3 not taken.
1064943 ((f2==mfPUSHLR || f2==mfPUSHLRNS|| f2==mfPUSHLRINS) && dir>=left) ||
19896
3/4
✓ Branch 0 taken 1064933 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1064933 times.
✗ Branch 3 not taken.
1064943 ((f2==mfPUSHU || f2==mfPUSHUNS || f2==mfPUSHUINS) && dir==up) ||
19897
3/4
✓ Branch 0 taken 1064933 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1064933 times.
✗ Branch 3 not taken.
1064943 ((f2==mfPUSHD || f2==mfPUSHDNS || f2==mfPUSHDINS) && dir==down) ||
19898
3/4
✓ Branch 0 taken 1064933 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1064933 times.
✗ Branch 3 not taken.
1064943 ((f2==mfPUSHL || f2==mfPUSHLNS || f2==mfPUSHLINS) && dir==left) ||
19899
3/4
✓ Branch 0 taken 1064933 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1064933 times.
✗ Branch 3 not taken.
1064943 ((f2==mfPUSHR || f2==mfPUSHRNS || f2==mfPUSHRINS) && dir==right) ||
19900
1/2
✓ Branch 0 taken 1064923 times.
✗ Branch 1 not taken.
1064933 f2==mfPUSH4 || f2==mfPUSH4NS || f2==mfPUSH4INS)&&(f!=mfPUSHED))
19901 {
19902 1 changecombo=true;
19903 1 doit=true;
19904 1 }
19905 }
19906
19907
2/2
✓ Branch 0 taken 315236 times.
✓ Branch 1 taken 749697 times.
1064933 if(get_bit(quest_rules,qr_SOLIDBLK))
19908 {
19909
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 82745 times.
✓ Branch 2 taken 73560 times.
✓ Branch 3 taken 71265 times.
✓ Branch 4 taken 87666 times.
315236 switch(blockdir)
19910 {
19911 case up:
19912
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 82745 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 82745 times.
✓ Branch 4 taken 51671 times.
✓ Branch 5 taken 31074 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 31074 times.
✓ Branch 8 taken 51675 times.
✓ Branch 9 taken 31070 times.
82745 if(_walkflag(bx,by-8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE)) doit=false;
19913
19914 82745 break;
19915
19916 case down:
19917
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 73560 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 73560 times.
✓ Branch 4 taken 44458 times.
✓ Branch 5 taken 29102 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 29102 times.
✓ Branch 8 taken 44462 times.
✓ Branch 9 taken 29098 times.
73560 if(_walkflag(bx,by+24,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE)) doit=false;
19918
19919 73560 break;
19920
19921 case left:
19922
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 71265 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 71265 times.
✓ Branch 4 taken 31068 times.
✓ Branch 5 taken 40197 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 40197 times.
✓ Branch 8 taken 31074 times.
✓ Branch 9 taken 40191 times.
71265 if(_walkflag(bx-16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE)) doit=false;
19923
19924 71265 break;
19925
19926 case right:
19927
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 87666 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 87666 times.
✓ Branch 4 taken 37161 times.
✓ Branch 5 taken 50505 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 50505 times.
✓ Branch 8 taken 37171 times.
✓ Branch 9 taken 50495 times.
87666 if(_walkflag(bx+16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE)) doit=false;
19928
19929 87666 break;
19930 }
19931 315236 }
19932
19933
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 386794 times.
✓ Branch 2 taken 329562 times.
✓ Branch 3 taken 165425 times.
✓ Branch 4 taken 183152 times.
1064933 switch(blockdir)
19934 {
19935 case up:
19936
3/4
✓ Branch 0 taken 386462 times.
✓ Branch 1 taken 332 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 386462 times.
386794 if((MAPFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS)) doit=false;
19937
19938 386794 break;
19939
19940 case down:
19941
3/4
✓ Branch 0 taken 329146 times.
✓ Branch 1 taken 416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 329146 times.
329562 if((MAPFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS)) doit=false;
19942
19943 329562 break;
19944
19945 case left:
19946
3/4
✓ Branch 0 taken 165343 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 165343 times.
165425 if((MAPFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS)) doit=false;
19947
19948 165425 break;
19949
19950 case right:
19951
3/4
✓ Branch 0 taken 183128 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 183128 times.
183152 if((MAPFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS)) doit=false;
19952
19953 183152 break;
19954 }
19955
19956
2/2
✓ Branch 0 taken 1063543 times.
✓ Branch 1 taken 1390 times.
1064933 if(doit)
19957 {
19958
2/2
✓ Branch 0 taken 1383 times.
✓ Branch 1 taken 7 times.
1390 if(limitedpush)
19959 7 ++usecounts[itemid];
19960
19961 // for(int32_t i=0; i<1; i++)
19962
2/2
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 1135 times.
1390 if(!blockmoving)
19963 {
19964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1135 times.
1135 if(changeflag)
19965 {
19966 1135 m->sflag[combopos]=0;
19967 1135 }
19968
19969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1135 times.
1135 if(mblock2.clk<=0)
19970 {
19971 1135 mblock2.blockLayer = lyr;
19972
19973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1135 times.
1135 if(t == cPUSHBLOCK)
19974 {
19975 zfix blockstep = 0.5;
19976 if(cmb.attrishorts[0] > 0)
19977 blockstep = zslongToFix(cmb.attrishorts[0]*100);
19978 mblock2.push_new(zfix(bx),zfix(by),blockdir,f,blockstep);
19979 mblock2.blockinfo = cpinfo;
19980 mblock2.blockinfo.push(blockdir, cmb.usrflags&cflag8);
19981 cpinfo.clear();
19982 if(cmb.attribytes[1])
19983 sfx(cmb.attribytes[1],(int32_t)x);
19984 }
19985 else
19986 {
19987 1135 mblock2.push((zfix)bx,(zfix)by,blockdir,f);
19988
19989
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1133 times.
1135 if(get_bit(quest_rules,qr_MORESOUNDS))
19990 2 sfx(WAV_ZN1PUSHBLOCK,(int32_t)x);
19991 }
19992 1135 }
19993 1135 }
19994 1390 break;
19995 }
19996 1063543 }
19997 6404312 }
19998
19999 249 bool usekey()
20000 {
20001 249 int32_t itemid = current_item_id(itype_magickey);
20002
20003
3/4
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 49 times.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
249 if(itemid<0 ||
20004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
20005 : itemsbuf[itemid].power!=dlevel))
20006 {
20007
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 165 times.
200 if(game->lvlkeys[dlevel]!=0)
20008 {
20009 35 game->lvlkeys[dlevel]--;
20010 //run script for level key item
20011 35 int32_t key_item = 0; //current_item_id(itype_lkey); //not possible
20012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2975 times.
2975 for ( int32_t q = 0; q < MAXITEMS; ++q )
20013 {
20014
2/2
✓ Branch 0 taken 2940 times.
✓ Branch 1 taken 35 times.
2975 if ( itemsbuf[q].family == itype_lkey )
20015 {
20016 35 key_item = q; break;
20017 }
20018 2940 }
20019
20020
2/8
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
35 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
20021 {
20022 ri = &(itemScriptData[key_item]);
20023 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
20024 ri->Clear();
20025 item_doscript[key_item] = 1;
20026 itemscriptInitialised[key_item] = 0;
20027 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
20028 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
20029 }
20030 35 return true;
20031 }
20032 else
20033 {
20034
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 124 times.
165 if(game->get_keys()==0)
20035 {
20036 41 return false;
20037 }
20038 else
20039 {
20040 //run script for key item
20041 124 int32_t key_item = 0; //current_item_id(itype_key); //not possible
20042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1240 times.
1240 for ( int32_t q = 0; q < MAXITEMS; ++q )
20043 {
20044
2/2
✓ Branch 0 taken 1116 times.
✓ Branch 1 taken 124 times.
1240 if ( itemsbuf[q].family == itype_key )
20045 {
20046 124 key_item = q; break;
20047 }
20048 1116 }
20049 //zprint2("key_item is: %d\n",key_item);
20050 //zprint2("key_item script is: %d\n",itemsbuf[key_item].script);
20051
2/8
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
124 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
20052 {
20053 ri = &(itemScriptData[key_item]);
20054 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
20055 ri->Clear();
20056 item_doscript[key_item] = 1;
20057 itemscriptInitialised[key_item] = 0;
20058 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
20059 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
20060 }
20061 124 game->change_keys(-1);
20062 }
20063 }
20064 124 }
20065
20066 173 return true;
20067 249 }
20068
20069 bool canUseKey(int32_t num)
20070 {
20071 int32_t itemid = current_item_id(itype_magickey);
20072
20073 if(itemid<0 ||
20074 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
20075 : itemsbuf[itemid].power!=dlevel))
20076 {
20077 return game->lvlkeys[dlevel] + game->get_keys() >= num;
20078 }
20079
20080 return true;
20081 }
20082
20083 bool usekey(int32_t num)
20084 {
20085 if(!canUseKey(num)) return false;
20086 for(auto q = 0; q < num; ++q)
20087 {
20088 if(!usekey()) return false; //should never return false here, but, just to be safe....
20089 }
20090 return true;
20091 }
20092
20093
20094 645 bool islockeddoor(int32_t x, int32_t y, int32_t lock)
20095 {
20096 645 int32_t mc = (y&0xF0)+(x>>4);
20097
4/6
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 645 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 609 times.
✓ Branch 5 taken 36 times.
1290 bool ret = (((mc==7||mc==8||mc==23||mc==24) && tmpscr->door[up]==lock)
20098
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 645 times.
✓ Branch 2 taken 645 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 645 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 645 times.
✗ Branch 7 not taken.
645 || ((mc==151||mc==152||mc==167||mc==168) && tmpscr->door[down]==lock)
20099
3/6
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 645 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 645 times.
✗ Branch 5 not taken.
645 || ((mc==64||mc==65||mc==80||mc==81) && tmpscr->door[left]==lock)
20100
5/8
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 645 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 637 times.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 637 times.
645 || ((mc==78||mc==79||mc==94||mc==95) && tmpscr->door[right]==lock));
20101 645 return ret;
20102 }
20103
20104 6381098 void HeroClass::oldchecklockblock()
20105 {
20106
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 6367692 times.
6381098 if(toogam) return;
20107
20108 6367692 int32_t bx = x.getInt()&0xF0;
20109 6367692 int32_t bx2 = int32_t(x+8)&0xF0;
20110 6367692 int32_t by = y.getInt()&0xF0;
20111
20112
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1521624 times.
✓ Branch 2 taken 1225463 times.
✓ Branch 3 taken 1736611 times.
✓ Branch 4 taken 1883994 times.
6367692 switch(dir)
20113 {
20114 case up:
20115
4/4
✓ Branch 0 taken 274836 times.
✓ Branch 1 taken 1246788 times.
✓ Branch 2 taken 5789 times.
✓ Branch 3 taken 269047 times.
1521624 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
20116
20117 1521624 break;
20118
20119 case down:
20120 1225463 by+=16;
20121 1225463 break;
20122
20123 case left:
20124
2/2
✓ Branch 0 taken 756539 times.
✓ Branch 1 taken 980072 times.
1736611 if((((int32_t)x)&0x0F)<8)
20125 980072 bx-=16;
20126
20127
2/2
✓ Branch 0 taken 1111011 times.
✓ Branch 1 taken 625600 times.
1736611 if(y.getInt()&8)
20128 {
20129 625600 by+=16;
20130 625600 }
20131
20132 1736611 bx2=bx;
20133 1736611 break;
20134
20135 case right:
20136 1883994 bx+=16;
20137
20138
2/2
✓ Branch 0 taken 1227303 times.
✓ Branch 1 taken 656691 times.
1883994 if(y.getInt()&8)
20139 {
20140 656691 by+=16;
20141 656691 }
20142
20143 1883994 bx2=bx;
20144 1883994 break;
20145 }
20146
20147 6367692 bool found1=false;
20148 6367692 bool found2=false;
20149 6367692 int32_t foundlayer = -1;
20150 6367692 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
20151 6367692 newcombo const& cmb = combobuf[cid1];
20152 6367692 newcombo const& cmb2 = combobuf[cid2];
20153 // Layer 0 is overridden by Locked Doors
20154
5/8
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 6367188 times.
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 504 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 504 times.
6367692 if((cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1) && !islockeddoor(bx,by,dLOCKED)))
20155 {
20156 504 found1=true;
20157 504 foundlayer = 0;
20158 504 }
20159
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6367188 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6367188 else if (cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, -1) && !islockeddoor(bx2,by,dLOCKED))
20160 {
20161 found2=true;
20162 foundlayer = 0;
20163 }
20164
20165
2/2
✓ Branch 0 taken 12735384 times.
✓ Branch 1 taken 6367692 times.
19103076 for (int32_t i = 0; i <= 1; ++i)
20166 {
20167
2/2
✓ Branch 0 taken 10889802 times.
✓ Branch 1 taken 1845582 times.
12735384 if(tmpscr2[i].valid!=0)
20168 {
20169
2/2
✓ Branch 0 taken 1737727 times.
✓ Branch 1 taken 107855 times.
1845582 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20170 {
20171
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1737727 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1737727 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
20172
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1737727 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1737727 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
20173 1737727 }
20174 else
20175 {
20176
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
20177
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
20178 }
20179 1845582 }
20180 12735384 }
20181
20182
20183 // Layers
20184
3/4
✓ Branch 0 taken 6367188 times.
✓ Branch 1 taken 504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6367188 times.
6367692 if(!(found1 || found2))
20185 {
20186 6367188 foundlayer = -1;
20187
2/2
✓ Branch 0 taken 6367154 times.
✓ Branch 1 taken 12734342 times.
19101496 for(int32_t i=0; i<2; i++)
20188 {
20189 12734342 cid1 = MAPCOMBO2(i, bx, by);
20190 12734342 cid2 = MAPCOMBO2(i, bx2, by);
20191 12734342 newcombo const& cmb = combobuf[cid1];
20192 12734342 newcombo const& cmb2 = combobuf[cid2];
20193
2/2
✓ Branch 0 taken 6367154 times.
✓ Branch 1 taken 6367188 times.
12734342 if (i == 0)
20194 {
20195
2/2
✓ Branch 0 taken 5999683 times.
✓ Branch 1 taken 367505 times.
6367188 if(tmpscr2[1].valid!=0)
20196 {
20197
2/2
✓ Branch 0 taken 322951 times.
✓ Branch 1 taken 44554 times.
367505 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20198 {
20199
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 322951 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
322951 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue; //Continue, because It didn't find any on layer 0, and if you're checking
20200
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 322951 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
322951 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue; //layer 1 and there's a bridge on layer 2, stop checking layer 1.
20201 322951 }
20202 else
20203 {
20204
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44554 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
20205
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44554 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
20206 }
20207 367505 }
20208 6367188 }
20209
4/6
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 12734308 times.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 34 times.
12734342 if(cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
20210 {
20211 34 found1=true;
20212 34 foundlayer = i+1;
20213 //zprint("Found layer: %d \n", i);
20214 34 break;
20215 }
20216
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12734308 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12734308 else if(cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, i))
20217 {
20218 found2=true;
20219 foundlayer = i+1;
20220 //zprint("Found layer: %d \n", i);
20221 break;
20222 }
20223 12734308 }
20224 6367188 }
20225
20226
4/4
✓ Branch 0 taken 6367154 times.
✓ Branch 1 taken 538 times.
✓ Branch 2 taken 6367643 times.
✓ Branch 3 taken 49 times.
6367692 if(!(found1 || found2) || pushing<8)
20227 {
20228 6367643 return;
20229 }
20230
1/2
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
49 newcombo const& cmb3 = combobuf[found1 ? cid1 : cid2];
20231
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 31 times.
49 if(!try_locked_combo(cmb3))
20232 31 return;
20233
20234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(cmb.usrflags&cflag16)
20235 {
20236 setxmapflag(1<<cmb.attribytes[5]);
20237 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
20238 }
20239 else
20240 {
20241 18 setmapflag(mLOCKBLOCK);
20242 18 remove_lockblocks((currscr>=128)?1:0);
20243 }
20244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( cmb3.usrflags&cflag3 )
20245 {
20246 if ( (cmb3.attribytes[3]) )
20247 sfx(cmb3.attribytes[3]);
20248 }
20249 18 else sfx(WAV_DOOR);
20250 6381098 }
20251
20252 6381098 void HeroClass::oldcheckbosslockblock()
20253 {
20254
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 6367692 times.
6381098 if(toogam) return;
20255
20256 6367692 int32_t bx = x.getInt()&0xF0;
20257 6367692 int32_t bx2 = int32_t(x+8)&0xF0;
20258 6367692 int32_t by = y.getInt()&0xF0;
20259
20260
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1521624 times.
✓ Branch 2 taken 1225463 times.
✓ Branch 3 taken 1736611 times.
✓ Branch 4 taken 1883994 times.
6367692 switch(dir)
20261 {
20262 case up:
20263
4/4
✓ Branch 0 taken 274836 times.
✓ Branch 1 taken 1246788 times.
✓ Branch 2 taken 5789 times.
✓ Branch 3 taken 269047 times.
1521624 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
20264
20265 1521624 break;
20266
20267 case down:
20268 1225463 by+=16;
20269 1225463 break;
20270
20271 case left:
20272
2/2
✓ Branch 0 taken 756539 times.
✓ Branch 1 taken 980072 times.
1736611 if((((int32_t)x)&0x0F)<8)
20273 980072 bx-=16;
20274
20275
2/2
✓ Branch 0 taken 1111011 times.
✓ Branch 1 taken 625600 times.
1736611 if(y.getInt()&8)
20276 {
20277 625600 by+=16;
20278 625600 }
20279
20280 1736611 bx2=bx;
20281 1736611 break;
20282
20283 case right:
20284 1883994 bx+=16;
20285
20286
2/2
✓ Branch 0 taken 1227303 times.
✓ Branch 1 taken 656691 times.
1883994 if(y.getInt()&8)
20287 {
20288 656691 by+=16;
20289 656691 }
20290
20291 1883994 bx2=bx;
20292 1883994 break;
20293 }
20294
20295
20296 6367692 bool found1 = false;
20297 6367692 bool found2 = false;
20298 6367692 int32_t foundlayer = -1;
20299 6367692 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
20300 6367692 newcombo const& cmb = combobuf[cid1];
20301 6367692 newcombo const& cmb2 = combobuf[cid2];
20302 // Layer 0 is overridden by Locked Doors
20303
5/8
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 6367551 times.
✓ Branch 2 taken 141 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 141 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 141 times.
6367692 if ((cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, -1) && !islockeddoor(bx, by, dLOCKED)))
20304 {
20305 141 found1 = true;
20306 141 foundlayer = 0;
20307 141 }
20308
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6367551 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6367551 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, -1) && !islockeddoor(bx2, by, dLOCKED))
20309 {
20310 found2 = true;
20311 foundlayer = 0;
20312 }
20313
20314
2/2
✓ Branch 0 taken 12735384 times.
✓ Branch 1 taken 6367692 times.
19103076 for (int32_t i = 0; i <= 1; ++i)
20315 {
20316
2/2
✓ Branch 0 taken 10889802 times.
✓ Branch 1 taken 1845582 times.
12735384 if (tmpscr2[i].valid != 0)
20317 {
20318
2/2
✓ Branch 0 taken 1737727 times.
✓ Branch 1 taken 107855 times.
1845582 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20319 {
20320
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1737727 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1737727 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
20321
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1737727 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1737727 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
20322 1737727 }
20323 else
20324 {
20325
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
20326
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
20327 }
20328 1845582 }
20329 12735384 }
20330
20331
20332 // Layers
20333
3/4
✓ Branch 0 taken 6367551 times.
✓ Branch 1 taken 141 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6367551 times.
6367692 if (!(found1 || found2))
20334 {
20335 6367551 foundlayer = -1;
20336
2/2
✓ Branch 0 taken 6367551 times.
✓ Branch 1 taken 12735102 times.
19102653 for (int32_t i = 0; i < 2; i++)
20337 {
20338 12735102 cid1 = MAPCOMBO2(i, bx, by);
20339 12735102 cid2 = MAPCOMBO2(i, bx2, by);
20340 12735102 newcombo const& cmb = combobuf[cid1];
20341 12735102 newcombo const& cmb2 = combobuf[cid2];
20342
2/2
✓ Branch 0 taken 6367551 times.
✓ Branch 1 taken 6367551 times.
12735102 if (i == 0)
20343 {
20344
2/2
✓ Branch 0 taken 5999903 times.
✓ Branch 1 taken 367648 times.
6367551 if (tmpscr2[1].valid != 0)
20345 {
20346
2/2
✓ Branch 0 taken 323030 times.
✓ Branch 1 taken 44618 times.
367648 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20347 {
20348
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 323030 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
323030 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
20349
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 323030 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
323030 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
20350 323030 }
20351 else
20352 {
20353
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44618 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
20354
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44618 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
20355 }
20356 367648 }
20357 6367551 }
20358
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12735102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12735102 if (cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, i))
20359 {
20360 found1 = true;
20361 foundlayer = i;
20362 break;
20363 }
20364
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12735102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12735102 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, i))
20365 {
20366 found2 = true;
20367 foundlayer = i;
20368 break;
20369 }
20370 12735102 }
20371 6367551 }
20372
20373
4/4
✓ Branch 0 taken 6367551 times.
✓ Branch 1 taken 141 times.
✓ Branch 2 taken 6367670 times.
✓ Branch 3 taken 22 times.
6367692 if (!(found1 || found2) || pushing < 8)
20374 {
20375 6367670 return;
20376 }
20377
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 int32_t cid = found1 ? cid1 : cid2;
20378
20379
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 17 times.
22 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
20380
20381
20382 // Run Boss Key Script
20383 5 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
20384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 for ( int32_t q = 0; q < MAXITEMS; ++q )
20385 {
20386
2/2
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 5 times.
340 if ( itemsbuf[q].family == itype_bosskey )
20387 {
20388 5 key_item = q; break;
20389 }
20390 335 }
20391
2/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
5 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
20392 {
20393 ri = &(itemScriptData[key_item]);
20394 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
20395 ri->Clear();
20396 item_doscript[key_item] = 1;
20397 itemscriptInitialised[key_item] = 0;
20398 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
20399 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
20400 }
20401
20402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(cmb.usrflags&cflag16)
20403 {
20404 setxmapflag(1<<cmb.attribytes[5]);
20405 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
20406 }
20407 else
20408 {
20409 5 setmapflag(mBOSSLOCKBLOCK);
20410 5 remove_bosslockblocks((currscr>=128)?1:0);
20411 }
20412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if ( (combobuf[cid].attribytes[3]) )
20413 5 sfx(combobuf[cid].attribytes[3]);
20414 6381098 }
20415
20416 18754293 void HeroClass::oldcheckchest(int32_t type)
20417 {
20418 // chests aren't affected by tmpscr->flags2&fAIRCOMBOS
20419
5/6
✓ Branch 0 taken 18714075 times.
✓ Branch 1 taken 40218 times.
✓ Branch 2 taken 18705018 times.
✓ Branch 3 taken 9057 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18705018 times.
18754293 if(toogam || z>0 || fakez > 0) return;
20420
2/2
✓ Branch 0 taken 17815902 times.
✓ Branch 1 taken 889116 times.
18705018 if(pushing<8) return;
20421 889116 int32_t bx = x.getInt()&0xF0;
20422 889116 int32_t bx2 = int32_t(x+8)&0xF0;
20423 889116 int32_t by = y.getInt()&0xF0;
20424
20425
3/4
✓ Branch 0 taken 498624 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180036 times.
✓ Branch 3 taken 210456 times.
889116 switch(dir)
20426 {
20427 case up:
20428
2/2
✓ Branch 0 taken 40752 times.
✓ Branch 1 taken 169704 times.
210456 if(isSideViewHero()) return;
20429
20430
4/4
✓ Branch 0 taken 49866 times.
✓ Branch 1 taken 119838 times.
✓ Branch 2 taken 48696 times.
✓ Branch 3 taken 1170 times.
169704 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
20431
20432 169704 break;
20433
20434 case left:
20435 case right:
20436
2/2
✓ Branch 0 taken 16173 times.
✓ Branch 1 taken 482451 times.
498624 if(isSideViewHero()) break;
20437 [[fallthrough]];
20438 case down:
20439 662487 return;
20440 }
20441
20442 185877 bool found=false;
20443 185877 bool itemflag=false;
20444
20445
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 185869 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
185877 if((combobuf[MAPCOMBO(bx,by)].type==type && _effectflag(bx,by,1, -1))||
20446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185869 times.
185869 (combobuf[MAPCOMBO(bx2,by)].type==type && _effectflag(bx2,by,1, -1)))
20447 {
20448 8 found=true;
20449 8 }
20450
2/2
✓ Branch 0 taken 371754 times.
✓ Branch 1 taken 185877 times.
557631 for (int32_t i = 0; i <= 1; ++i)
20451 {
20452
2/2
✓ Branch 0 taken 323814 times.
✓ Branch 1 taken 47940 times.
371754 if(tmpscr2[i].valid!=0)
20453 {
20454
2/2
✓ Branch 0 taken 47079 times.
✓ Branch 1 taken 861 times.
47940 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20455 {
20456
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 47079 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
47079 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
20457
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 47079 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
47079 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
20458 47079 }
20459 else
20460 {
20461
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
861 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
20462
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
861 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
20463 }
20464 47940 }
20465 371754 }
20466
20467
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 185869 times.
185877 if(!found)
20468 {
20469
2/2
✓ Branch 0 taken 185869 times.
✓ Branch 1 taken 371738 times.
557607 for(int32_t i=0; i<2; i++)
20470 {
20471
2/2
✓ Branch 0 taken 185869 times.
✓ Branch 1 taken 185869 times.
371738 if (i == 0)
20472 {
20473
2/2
✓ Branch 0 taken 177694 times.
✓ Branch 1 taken 8175 times.
185869 if(tmpscr2[1].valid!=0)
20474 {
20475
2/2
✓ Branch 0 taken 7794 times.
✓ Branch 1 taken 381 times.
8175 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20476 {
20477
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7794 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7794 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
20478
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7794 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7794 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
20479 7794 }
20480 else
20481 {
20482
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
381 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
20483
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
381 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
20484 }
20485 8175 }
20486 185869 }
20487
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 371738 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
371738 if((combobuf[MAPCOMBO2(i,bx,by)].type==type && _effectflag(bx,by,1, i))||
20488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 371738 times.
371738 (combobuf[MAPCOMBO2(i,bx2,by)].type==type && _effectflag(bx2,by,1, i)))
20489 {
20490 found=true;
20491 break;
20492 }
20493 371738 }
20494 185869 }
20495
20496
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 185869 times.
185877 if(!found)
20497 {
20498 185869 return;
20499 }
20500
20501
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 switch(type)
20502 {
20503 case cLOCKEDCHEST:
20504 if(!usekey()) return;
20505
20506 setmapflag(mLOCKEDCHEST);
20507 break;
20508
20509 case cCHEST:
20510 8 setmapflag(mCHEST);
20511 8 break;
20512
20513 case cBOSSCHEST:
20514 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
20515 // Run Boss Key Script
20516 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
20517 for ( int32_t q = 0; q < MAXITEMS; ++q )
20518 {
20519 if ( itemsbuf[q].family == itype_bosskey )
20520 {
20521 key_item = q; break;
20522 }
20523 }
20524 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
20525 {
20526 ri = &(itemScriptData[key_item]);
20527 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
20528 ri->Clear();
20529 item_doscript[key_item] = 1;
20530 itemscriptInitialised[key_item] = 0;
20531 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
20532 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
20533 }
20534 setmapflag(mBOSSCHEST);
20535 break;
20536 }
20537
20538 8 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
20539 8 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
20540 8 itemflag |= MAPFLAG(bx,by)==mfARMOS_ITEM;
20541 8 itemflag |= MAPFLAG(bx2,by)==mfARMOS_ITEM;
20542 8 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
20543 8 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
20544
20545
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!itemflag)
20546 {
20547 for(int32_t i=0; i<2; i++)
20548 {
20549 itemflag |= MAPFLAG2(i,bx,by)==mfARMOS_ITEM;
20550 itemflag |= MAPFLAG2(i,bx2,by)==mfARMOS_ITEM;
20551 itemflag |= MAPCOMBOFLAG2(i,bx,by)==mfARMOS_ITEM;
20552 itemflag |= MAPCOMBOFLAG2(i,bx2,by)==mfARMOS_ITEM;
20553 }
20554 }
20555
20556
3/6
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
8 if(itemflag && !getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM))
20557 {
20558
4/8
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
8 items.add(new item(x, y,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
20559 8 }
20560 18754293 }
20561
20562 529710 void HeroClass::checkchest(int32_t type)
20563 {
20564
4/4
✓ Branch 0 taken 371904 times.
✓ Branch 1 taken 157806 times.
✓ Branch 2 taken 157806 times.
✓ Branch 3 taken 214098 times.
529710 bool ischest = type == cCHEST || type == cLOCKEDCHEST || type == cBOSSCHEST;
20565
2/2
✓ Branch 0 taken 28146 times.
✓ Branch 1 taken 501564 times.
529710 bool islockblock = type == cLOCKBLOCK || type == cBOSSLOCKBLOCK;
20566
2/2
✓ Branch 0 taken 28146 times.
✓ Branch 1 taken 501564 times.
529710 bool islocked = type == cLOCKBLOCK || type == cLOCKEDCHEST;
20567
2/2
✓ Branch 0 taken 28146 times.
✓ Branch 1 taken 501564 times.
529710 bool isbosslocked = type == cBOSSLOCKBLOCK || type == cBOSSCHEST;
20568
2/2
✓ Branch 0 taken 56292 times.
✓ Branch 1 taken 473418 times.
529710 if(ischest)
20569 {
20570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473418 times.
473418 if(get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
20571 {
20572 oldcheckchest(type);
20573 return;
20574 }
20575 473418 }
20576
3/4
✓ Branch 0 taken 56292 times.
✓ Branch 1 taken 473418 times.
✓ Branch 2 taken 56292 times.
✗ Branch 3 not taken.
529710 if(islockblock && get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
20577 {
20578 if(type == cLOCKBLOCK)
20579 oldchecklockblock();
20580 else if(type == cBOSSLOCKBLOCK)
20581 oldcheckbosslockblock();
20582 return;
20583 }
20584
4/6
✓ Branch 0 taken 529710 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 527134 times.
✓ Branch 3 taken 2576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 527134 times.
529710 if(toogam || z>0 || fakez > 0) return;
20585 527134 zfix bx, by;
20586 527134 zfix bx2, by2;
20587 527134 zfix fx(-1), fy(-1);
20588
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 106403 times.
✓ Branch 2 taken 119134 times.
✓ Branch 3 taken 139244 times.
✓ Branch 4 taken 162353 times.
527134 switch(dir)
20589 {
20590 case up:
20591 106403 by = y + (bigHitbox ? -2 : 6);
20592 106403 by2 = by;
20593 106403 bx = x + 4;
20594 106403 bx2 = bx + 8;
20595 106403 break;
20596 case down:
20597 119134 by = y + 17;
20598 119134 by2 = by;
20599 119134 bx = x + 4;
20600 119134 bx2 = bx + 8;
20601 119134 break;
20602 case left:
20603 139244 by = y + (bigHitbox ? 0 : 8);
20604 139244 by2 = y + 8;
20605 139244 bx = x - 2;
20606 139244 bx2 = x - 2;
20607 139244 break;
20608 case right:
20609 162353 by = y + (bigHitbox ? 0 : 8);
20610 162353 by2 = y + 8;
20611 162353 bx = x + 17;
20612 162353 bx2 = x + 17;
20613 162353 break;
20614 }
20615
20616 527134 int32_t found = -1;
20617 527134 int32_t foundlayer = 0;
20618
20619 527134 newcombo const* cmb = &combobuf[MAPCOMBO(bx,by)];
20620
20621
4/6
✓ Branch 0 taken 871 times.
✓ Branch 1 taken 526263 times.
✓ Branch 2 taken 871 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 871 times.
527134 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1))
20622 {
20623 871 found = MAPCOMBO(bx,by);
20624 871 fx = bx; fy = by;
20625
2/2
✓ Branch 0 taken 1742 times.
✓ Branch 1 taken 871 times.
2613 for (int32_t i = 0; i <= 1; ++i)
20626 {
20627
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 1357 times.
1742 if(tmpscr2[i].valid!=0)
20628 {
20629
1/2
✓ Branch 0 taken 1357 times.
✗ Branch 1 not taken.
1357 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20630 {
20631
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1357 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1357 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
20632 1357 }
20633 else
20634 {
20635 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
20636 }
20637 1357 }
20638 1742 }
20639 871 }
20640
2/2
✓ Branch 0 taken 871 times.
✓ Branch 1 taken 526263 times.
527134 if(found<0)
20641 {
20642 526263 cmb = &combobuf[MAPCOMBO(bx2,by2)];
20643
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 526240 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
526263 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, -1))
20644 {
20645 23 found = MAPCOMBO(bx2,by2);
20646
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 161 times.
184 for (int32_t i = 0; i <= 6; ++i)
20647 {
20648
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 46 times.
161 if(tmpscr2[i].valid!=0)
20649 {
20650
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20651 {
20652
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
46 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i])))
20653 {
20654 found = -1;
20655 break;
20656 }
20657 46 }
20658 else
20659 {
20660 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i])))
20661 {
20662 found = -1;
20663 break;
20664 }
20665 }
20666 46 }
20667 161 }
20668
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(found != -1)
20669 {
20670 23 fx = bx2; fy = by2;
20671 23 }
20672 23 }
20673 526263 }
20674
20675
2/2
✓ Branch 0 taken 894 times.
✓ Branch 1 taken 526240 times.
527134 if(found<0)
20676 {
20677
2/2
✓ Branch 0 taken 526187 times.
✓ Branch 1 taken 3157175 times.
3683362 for(int32_t i=0; i<6; i++)
20678 {
20679 3157175 cmb = &combobuf[MAPCOMBO2(i,bx,by)];
20680
4/6
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 3157122 times.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 53 times.
3157175 if(combobuf[MAPCOMBO2(i,bx,by)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
20681 {
20682 53 found = MAPCOMBO2(i,bx,by);
20683
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 265 times.
318 for(int32_t j = i+1; j < 6; ++j)
20684 {
20685
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 53 times.
265 if (tmpscr2[j].valid!=0)
20686 {
20687
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20688 {
20689
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[j])))
20690 {
20691 found = -1;
20692 break;
20693 }
20694 53 }
20695 else
20696 {
20697 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[j])))
20698 {
20699 found = -1;
20700 break;
20701 }
20702 }
20703 53 }
20704 265 }
20705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(found>-1)
20706 {
20707 53 foundlayer = i+1;
20708 53 fx = bx; fy = by;
20709 53 break;
20710 }
20711 }
20712 3157122 cmb = &combobuf[MAPCOMBO2(i,bx2,by2)];
20713
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3157122 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3157122 if(combobuf[MAPCOMBO2(i,bx2,by2)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, i))
20714 {
20715 found = MAPCOMBO2(i,bx2,by2);
20716 for(int32_t j = i+1; j < 6; ++j)
20717 {
20718 if (tmpscr2[j].valid!=0)
20719 {
20720 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20721 {
20722 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[j])))
20723 {
20724 found = -1;
20725 break;
20726 }
20727 }
20728 else
20729 {
20730 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[j])))
20731 {
20732 found = -1;
20733 break;
20734 }
20735 }
20736 }
20737 }
20738 if(found>-1)
20739 {
20740 foundlayer = i+1;
20741 fx = bx2; fy = by2;
20742 break;
20743 }
20744 }
20745 3157122 }
20746 526240 }
20747
20748
2/2
✓ Branch 0 taken 947 times.
✓ Branch 1 taken 526187 times.
527134 if(found<0) return;
20749 947 cmb = &combobuf[found];
20750
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
947 switch(dir)
20751 {
20752 case up:
20753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
947 if(cmb->usrflags&cflag10)
20754 return;
20755 947 break;
20756 case down:
20757 if(cmb->usrflags&cflag9)
20758 return;
20759 break;
20760 case left:
20761 if(cmb->usrflags&cflag12)
20762 return;
20763 break;
20764 case right:
20765 if(cmb->usrflags&cflag11)
20766 return;
20767 break;
20768 }
20769 947 int32_t intbtn = cmb->attribytes[2];
20770
20771
1/2
✓ Branch 0 taken 947 times.
✗ Branch 1 not taken.
947 if(intbtn) //
20772 {
20773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
947 if(cmb->usrflags & cflag13) //display prompt
20774 {
20775 947 int altcmb = cmb->attributes[2]/10000;
20776 947 prompt_combo = cmb->attributes[1]/10000;
20777
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
947 if(altcmb && ((islocked && !can_locked_combo(*cmb))
20778 || (isbosslocked && !(game->lvlitems[dlevel]&liBOSSKEY))))
20779 prompt_combo = altcmb;
20780 947 prompt_cset = cmb->attribytes[4];
20781 947 prompt_x = cmb->attrishorts[0];
20782 947 prompt_y = cmb->attrishorts[1];
20783 947 }
20784
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 935 times.
947 if(!getIntBtnInput(intbtn, true, true, false, false))
20785 {
20786 935 return; //Button not pressed
20787 }
20788 12 }
20789 else if(pushing < 8) return; //Not pushing against chest enough
20790
20791
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(ischest)
20792 {
20793
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!trigger_chest(foundlayer, COMBOPOS(fx,fy))) return;
20794 12 }
20795 else if(islockblock)
20796 {
20797 if(!trigger_lockblock(foundlayer, COMBOPOS(fx,fy))) return;
20798 }
20799
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(intbtn && (cmb->usrflags & cflag13))
20800 12 prompt_combo = 0;
20801 529710 }
20802
20803 6419923 void HeroClass::checkgenpush()
20804 {
20805
4/4
✓ Branch 0 taken 301156 times.
✓ Branch 1 taken 6118767 times.
✓ Branch 2 taken 257243 times.
✓ Branch 3 taken 43913 times.
6419923 if(pushing < 8 || pushing % 8) return;
20806 43913 zfix bx, by;
20807 43913 zfix bx2, by2;
20808
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 10532 times.
✓ Branch 2 taken 9114 times.
✓ Branch 3 taken 11637 times.
✓ Branch 4 taken 12630 times.
43913 switch(dir)
20809 {
20810 case up:
20811 10532 by = y + (bigHitbox ? -2 : 6);
20812 10532 by2 = by;
20813 10532 bx = x + 4;
20814 10532 bx2 = bx + 8;
20815 10532 break;
20816 case down:
20817 9114 by = y + 17;
20818 9114 by2 = by;
20819 9114 bx = x + 4;
20820 9114 bx2 = bx + 8;
20821 9114 break;
20822 case left:
20823 11637 by = y + (bigHitbox ? 0 : 8);
20824 11637 by2 = y + 8;
20825 11637 bx = x - 2;
20826 11637 bx2 = x - 2;
20827 11637 break;
20828 case right:
20829 12630 by = y + (bigHitbox ? 0 : 8);
20830 12630 by2 = y + 8;
20831 12630 bx = x + 17;
20832 12630 bx2 = x + 17;
20833 12630 break;
20834 }
20835 43913 auto pos1 = COMBOPOS(bx,by);
20836 43913 auto pos2 = COMBOPOS(bx2,by2);
20837
2/2
✓ Branch 0 taken 43913 times.
✓ Branch 1 taken 307391 times.
351304 for(auto layer = 0; layer < 7; ++layer)
20838 {
20839 307391 mapscr* tmp = FFCore.tempScreens[layer];
20840
20841 307391 newcombo const& cmb1 = combobuf[tmp->data[pos1]];
20842
2/2
✓ Branch 0 taken 307390 times.
✓ Branch 1 taken 1 times.
307391 if(cmb1.triggerflags[1] & combotriggerPUSH)
20843 1 do_trigger_combo(layer,pos1);
20844
20845
2/2
✓ Branch 0 taken 259735 times.
✓ Branch 1 taken 47656 times.
307391 if(pos1==pos2) continue;
20846
20847 47656 newcombo const& cmb2 = combobuf[tmp->data[pos2]];
20848
1/2
✓ Branch 0 taken 47656 times.
✗ Branch 1 not taken.
47656 if(cmb2.triggerflags[1] & combotriggerPUSH)
20849 do_trigger_combo(layer,pos2);
20850 47656 }
20851
2/2
✓ Branch 0 taken 822 times.
✓ Branch 1 taken 43091 times.
43913 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
20852 {
20853 822 word c = tmpscr->numFFC();
20854
2/2
✓ Branch 0 taken 822 times.
✓ Branch 1 taken 5127 times.
5949 for(word i=0; i<c; i++)
20855 {
20856
4/4
✓ Branch 0 taken 5056 times.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 5046 times.
5127 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
20857 {
20858 81 ffcdata& ffc = tmpscr->ffcs[i];
20859 81 newcombo const& cmb3 = combobuf[ffc.getData()];
20860
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(cmb3.triggerflags[1] & combotriggerPUSH)
20861 {
20862 do_trigger_combo_ffc(i);
20863 break;
20864 }
20865 81 }
20866 5127 }
20867 822 }
20868 6419923 }
20869
20870 6419924 void HeroClass::checksigns() //Also checks for generic trigger buttons
20871 {
20872
5/6
✓ Branch 0 taken 6406518 times.
✓ Branch 1 taken 13406 times.
✓ Branch 2 taken 6402877 times.
✓ Branch 3 taken 3641 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6402877 times.
6419924 if(toogam || z>0 || fakez>0) return;
20873
5/6
✓ Branch 0 taken 6354522 times.
✓ Branch 1 taken 48355 times.
✓ Branch 2 taken 107120 times.
✓ Branch 3 taken 6247402 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 107120 times.
6402877 if(msg_active || (msg_onscreen && get_bit(quest_rules, qr_MSGDISAPPEAR)))
20874 48355 return; //Don't overwrite a message waiting to be dismissed
20875 6354522 zfix bx, by;
20876 6354522 zfix bx2, by2;
20877 6354522 zfix fx(-1), fy(-1);
20878
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1485691 times.
✓ Branch 2 taken 1230390 times.
✓ Branch 3 taken 1739302 times.
✓ Branch 4 taken 1899139 times.
6354522 switch(dir)
20879 {
20880 case up:
20881 1485691 by = y + (bigHitbox ? -2 : 6);
20882 1485691 by2 = by;
20883 1485691 bx = x + 4;
20884 1485691 bx2 = bx + 8;
20885 1485691 break;
20886 case down:
20887 1230390 by = y + 17;
20888 1230390 by2 = by;
20889 1230390 bx = x + 4;
20890 1230390 bx2 = bx + 8;
20891 1230390 break;
20892 case left:
20893 1739302 by = y + (bigHitbox ? 0 : 8);
20894 1739302 by2 = y + 8;
20895 1739302 bx = x - 2;
20896 1739302 bx2 = x - 2;
20897 1739302 break;
20898 case right:
20899 1899139 by = y + (bigHitbox ? 0 : 8);
20900 1899139 by2 = y + 8;
20901 1899139 bx = x + 17;
20902 1899139 bx2 = x + 17;
20903 1899139 break;
20904 }
20905
20906 6354522 int32_t found = -1;
20907 6354522 int32_t foundffc = -1;
20908 6354522 int32_t found_lyr = 0;
20909 6354522 bool found_sign = false;
20910 6354522 int32_t tmp_cid = MAPCOMBO(bx,by);
20911 6354522 newcombo const* tmp_cmb = &combobuf[tmp_cid];
20912
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6354522 times.
✓ Branch 2 taken 6353876 times.
✓ Branch 3 taken 646 times.
12709044 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
20913 6354522 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, -1))
20914 {
20915 646 found = tmp_cid;
20916 646 fx = bx; fy = by;
20917
2/2
✓ Branch 0 taken 1292 times.
✓ Branch 1 taken 646 times.
1938 for (int32_t i = 0; i <= 1; ++i)
20918 {
20919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
1292 if(tmpscr2[i].valid!=0)
20920 {
20921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
1292 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20922 {
20923 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
20924 }
20925 else
20926 {
20927
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1292 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
20928 }
20929 1292 }
20930 1292 }
20931 646 }
20932 6354522 tmp_cid = MAPCOMBO(bx2,by2);
20933 6354522 tmp_cmb = &combobuf[tmp_cid];
20934
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6354522 times.
✓ Branch 2 taken 6353936 times.
✓ Branch 3 taken 586 times.
12709044 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
20935 6354522 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, -1))
20936 {
20937 586 found = tmp_cid;
20938 586 fx = bx2; fy = by2;
20939
2/2
✓ Branch 0 taken 1172 times.
✓ Branch 1 taken 586 times.
1758 for (int32_t i = 0; i <= 1; ++i)
20940 {
20941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1172 times.
1172 if(tmpscr2[i].valid!=0)
20942 {
20943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1172 times.
1172 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20944 {
20945 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
20946 }
20947 else
20948 {
20949
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1172 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1172 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
20950 }
20951 1172 }
20952 1172 }
20953 586 }
20954
20955
2/2
✓ Branch 0 taken 6197622 times.
✓ Branch 1 taken 156900 times.
6354522 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
20956 {
20957 156900 word c = tmpscr->numFFC();
20958
2/2
✓ Branch 0 taken 156900 times.
✓ Branch 1 taken 889228 times.
1046128 for(word i=0; i<c; i++)
20959 {
20960
4/4
✓ Branch 0 taken 881868 times.
✓ Branch 1 taken 7360 times.
✓ Branch 2 taken 547 times.
✓ Branch 3 taken 881321 times.
889228 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
20961 {
20962 7907 ffcdata& ffc = tmpscr->ffcs[i];
20963 7907 tmp_cmb = &combobuf[ffc.getData()];
20964
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7907 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7907 times.
7907 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
20965 7907 || tmp_cmb->triggerbtn) && true) //!TODO: FFC effect flag?
20966 {
20967 foundffc = i;
20968 break;
20969 }
20970 7907 }
20971 889228 }
20972 156900 }
20973
20974
3/4
✓ Branch 0 taken 6353873 times.
✓ Branch 1 taken 649 times.
✓ Branch 2 taken 6353873 times.
✗ Branch 3 not taken.
6354522 if(found<0 && foundffc < 0)
20975 {
20976
2/2
✓ Branch 0 taken 6353301 times.
✓ Branch 1 taken 38120378 times.
44473679 for(int32_t i=0; i<6; i++)
20977 {
20978 38120378 tmp_cid = MAPCOMBO2(i,bx,by);
20979 38120378 tmp_cmb = &combobuf[tmp_cid];
20980
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38120378 times.
✓ Branch 2 taken 38119806 times.
✓ Branch 3 taken 572 times.
76240756 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
20981 38120378 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, i))
20982 {
20983 572 found = tmp_cid;
20984 572 found_lyr = i+1;
20985 572 fx = bx; fy = by;
20986
3/4
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 440 times.
572 if (i == 0 && tmpscr2[1].valid!=0)
20987 {
20988
1/2
✓ Branch 0 taken 440 times.
✗ Branch 1 not taken.
440 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20989 {
20990
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
440 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
20991 440 }
20992 else
20993 {
20994 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
20995 }
20996 440 }
20997 572 }
20998 38120378 tmp_cid = MAPCOMBO2(i,bx2,by2);
20999 38120378 tmp_cmb = &combobuf[tmp_cid];
21000
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38120378 times.
✓ Branch 2 taken 38119862 times.
✓ Branch 3 taken 516 times.
76240756 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
21001 38120378 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, i))
21002 {
21003 516 found = tmp_cid;
21004 516 found_lyr = i+1;
21005 516 fx = bx2; fy = by2;
21006
3/4
✓ Branch 0 taken 516 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 390 times.
516 if (i == 0 && tmpscr2[1].valid!=0)
21007 {
21008
1/2
✓ Branch 0 taken 390 times.
✗ Branch 1 not taken.
390 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
21009 {
21010
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
390 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
21011 390 }
21012 else
21013 {
21014 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
21015 }
21016 390 }
21017 516 }
21018
2/2
✓ Branch 0 taken 38119806 times.
✓ Branch 1 taken 572 times.
38120378 if(found>-1) break;
21019 38119806 }
21020 6353873 }
21021
21022
3/4
✓ Branch 0 taken 6353301 times.
✓ Branch 1 taken 1221 times.
✓ Branch 2 taken 6353301 times.
✗ Branch 3 not taken.
6354522 if(found<0&&foundffc<0) return;
21023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1221 times.
1221 newcombo const& cmb = (foundffc<0?combobuf[found]:combobuf[tmpscr->ffcs[foundffc].getData()]);
21024
21025 1221 byte signInput = 0;
21026 1221 bool didsign = false;
21027
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1221 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1221 if(cmb.type == cSIGNPOST && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
21028 {
21029 switch(dir)
21030 {
21031 case up:
21032 if(cmb.usrflags&cflag10)
21033 goto endsigns;
21034 break;
21035 case down:
21036 if(cmb.usrflags&cflag9)
21037 goto endsigns;
21038 break;
21039 case left:
21040 if(cmb.usrflags&cflag12)
21041 goto endsigns;
21042 break;
21043 case right:
21044 if(cmb.usrflags&cflag11)
21045 goto endsigns;
21046 break;
21047 }
21048 int32_t intbtn = cmb.attribytes[2];
21049
21050 if(intbtn) //
21051 {
21052 signInput = getIntBtnInput(intbtn, true, true, false, false);
21053 if(!signInput)
21054 {
21055 if(cmb.usrflags & cflag13) //display prompt
21056 {
21057 prompt_combo = cmb.attributes[1]/10000;
21058 prompt_cset = cmb.attribytes[4];
21059 prompt_x = cmb.attrishorts[0];
21060 prompt_y = cmb.attrishorts[1];
21061 }
21062 goto endsigns; //Button not pressed
21063 }
21064 }
21065 else if(pushing < 8 || pushing%8) goto endsigns; //Not pushing against sign enough
21066
21067 trigger_sign(cmb);
21068 didsign = true;
21069 }
21070 endsigns:
21071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1221 times.
1221 if(on_cooldown(found_lyr, COMBOPOS(fx,fy))) return;
21072
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 253 times.
✓ Branch 2 taken 431 times.
✓ Branch 3 taken 309 times.
✓ Branch 4 taken 228 times.
1221 switch(dir)
21073 {
21074 case down:
21075
1/2
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
253 if(!(cmb.triggerflags[0] & combotriggerBTN_TOP))
21076 return;
21077 253 break;
21078 case up:
21079
1/2
✓ Branch 0 taken 431 times.
✗ Branch 1 not taken.
431 if(!(cmb.triggerflags[0] & combotriggerBTN_BOTTOM))
21080 return;
21081 431 break;
21082 case right:
21083
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 if(!(cmb.triggerflags[0] & combotriggerBTN_LEFT))
21084 return;
21085 309 break;
21086 case left:
21087
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 75 times.
228 if(!(cmb.triggerflags[0] & combotriggerBTN_RIGHT))
21088 75 return;
21089 153 break;
21090 }
21091
4/6
✓ Branch 0 taken 1146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1114 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1114 times.
1146 if(cmb.triggerbtn && (getIntBtnInput(cmb.triggerbtn, true, true, false, false) || checkIntBtnVal(cmb.triggerbtn, signInput)))
21092 {
21093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if (foundffc >= 0)
21094 do_trigger_combo_ffc(foundffc, didsign ? ctrigIGNORE_SIGN : 0);
21095 else
21096 32 do_trigger_combo(found_lyr, COMBOPOS(fx,fy), didsign ? ctrigIGNORE_SIGN : 0);
21097 32 }
21098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1114 times.
1114 else if(cmb.type == cBUTTONPROMPT)
21099 {
21100 prompt_combo = cmb.attributes[0]/10000;
21101 prompt_cset = cmb.attribytes[0];
21102 prompt_x = cmb.attrishorts[0];
21103 prompt_y = cmb.attrishorts[1];
21104 }
21105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1114 times.
1114 else if(cmb.prompt_cid)
21106 {
21107 1114 prompt_combo = cmb.prompt_cid;
21108 1114 prompt_cset = cmb.prompt_cs;
21109 1114 prompt_x = cmb.prompt_x;
21110 1114 prompt_y = cmb.prompt_y;
21111 1114 }
21112 6419924 }
21113
21114 6409244 void HeroClass::checklocked()
21115 {
21116
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 6395838 times.
6409244 if(toogam) return; //Walk through walls.
21117
21118
2/2
✓ Branch 0 taken 3646290 times.
✓ Branch 1 taken 2749548 times.
6395838 if(!isdungeon()) return;
21119
21120
4/4
✓ Branch 0 taken 3645652 times.
✓ Branch 1 taken 638 times.
✓ Branch 2 taken 7738 times.
✓ Branch 3 taken 3637914 times.
3646290 if( !diagonalMovement && pushing!=8) return;
21121 /*This is required to allow the player to open a door, while sliding along a wall (pressing in the direction of the door, and sliding left or right)
21122 */
21123
4/4
✓ Branch 0 taken 638 times.
✓ Branch 1 taken 7738 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 628 times.
8376 if ( diagonalMovement && pushing < 8 ) return; //Allow wall walking Should I add a quest rule for this? -Z
21124
21125
21126 7748 bool found = false;
21127
2/2
✓ Branch 0 taken 30992 times.
✓ Branch 1 taken 7748 times.
38740 for ( int32_t q = 0; q < 4; q++ ) {
21128
4/4
✓ Branch 0 taken 30264 times.
✓ Branch 1 taken 728 times.
✓ Branch 2 taken 246 times.
✓ Branch 3 taken 30018 times.
30992 if ( tmpscr->door[q] == dLOCKED || tmpscr->door[q] == dBOSS ) { found = true; }
21129 30992 }
21130
21131
2/2
✓ Branch 0 taken 943 times.
✓ Branch 1 taken 6805 times.
7748 if ( !found ) return;
21132
21133 943 int32_t si = (currmap<<7) + currscr;
21134 943 int32_t di = 0;
21135
21136
21137
21138
2/4
✓ Branch 0 taken 943 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 943 times.
943 if ( diagonalMovement || get_bit(quest_rules, qr_DISABLE_4WAY_GRIDLOCK))
21139 {
21140 //Up door
21141 if ( y <= 32 && x >= 112 && x <= 128 )
21142 {
21143 if (
21144 dir == up || dir == l_up || dir == r_up //|| Up() || ( Up()&&Left()) || ( Up()&&Right())
21145
21146 )
21147 {
21148 di = nextscr(up);
21149 if(tmpscr->door[0]==dLOCKED)
21150 {
21151 if(usekey())
21152 {
21153 putdoor(scrollbuf,0,up,dUNLOCKED);
21154 tmpscr->door[0]=dUNLOCKED;
21155 setmapflag(si, mDOOR_UP);
21156
21157 if(di != 0xFFFF)
21158 setmapflag(di, mDOOR_DOWN);
21159 sfx(WAV_DOOR);
21160 markBmap(-1);
21161 }
21162 else return;
21163 }
21164 else if(tmpscr->door[0]==dBOSS)
21165 {
21166 if(game->lvlitems[dlevel]&liBOSSKEY)
21167 {
21168 putdoor(scrollbuf,0,up,dOPENBOSS);
21169 tmpscr->door[0]=dOPENBOSS;
21170 setmapflag(si, mDOOR_UP);
21171
21172 if(di != 0xFFFF)
21173 setmapflag(di, mDOOR_DOWN);
21174 sfx(WAV_DOOR);
21175 markBmap(-1);
21176 // Run Boss Key Script
21177 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21178 for ( int32_t q = 0; q < MAXITEMS; ++q )
21179 {
21180 if ( itemsbuf[q].family == itype_bosskey )
21181 {
21182 key_item = q; break;
21183 }
21184 }
21185 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
21186 {
21187 ri = &(itemScriptData[key_item]);
21188 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
21189 ri->Clear();
21190 item_doscript[key_item] = 1;
21191 itemscriptInitialised[key_item] = 0;
21192 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
21193 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
21194 }
21195 }
21196 else return;
21197
21198 }
21199
21200 }
21201 }
21202 //Down
21203 if ( y >= 128 && x >= 112 && x <= 128 )
21204 {
21205 if ( dir == down || dir == l_down || dir == r_down ) //|| Down() || ( Down()&&Left()) || ( Down()&&Right()))
21206 {
21207 di = nextscr(down);
21208 if(tmpscr->door[1]==dLOCKED)
21209 {
21210 if(usekey())
21211 {
21212 putdoor(scrollbuf,0,down,dUNLOCKED);
21213 tmpscr->door[1]=dUNLOCKED;
21214 setmapflag(si, mDOOR_DOWN);
21215
21216 if(di != 0xFFFF)
21217 setmapflag(di, mDOOR_UP);
21218 sfx(WAV_DOOR);
21219 markBmap(-1);
21220 }
21221 else return;
21222 }
21223 else if(tmpscr->door[1]==dBOSS)
21224 {
21225 if(game->lvlitems[dlevel]&liBOSSKEY)
21226 {
21227 putdoor(scrollbuf,0,down,dOPENBOSS);
21228 tmpscr->door[1]=dOPENBOSS;
21229 setmapflag(si, mDOOR_DOWN);
21230
21231 if(di != 0xFFFF)
21232 setmapflag(di, mDOOR_UP);
21233 sfx(WAV_DOOR);
21234 markBmap(-1);
21235 // Run Boss Key Script
21236 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21237 for ( int32_t q = 0; q < MAXITEMS; ++q )
21238 {
21239 if ( itemsbuf[q].family == itype_bosskey )
21240 {
21241 key_item = q; break;
21242 }
21243 }
21244 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
21245 {
21246 ri = &(itemScriptData[key_item]);
21247 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
21248 ri->Clear();
21249 item_doscript[key_item] = 1;
21250 itemscriptInitialised[key_item] = 0;
21251 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
21252 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
21253 }
21254 }
21255 else return;
21256 }
21257 }
21258 }
21259 //left
21260 if ( y > 72 && y < 88 && x <= 32 )
21261 {
21262 if ( dir == left || dir == l_up || dir == l_down )//|| Left() || ( Up()&&Left()) || ( Down()&&Left() ) )
21263 {
21264 di = nextscr(left);
21265 if(tmpscr->door[2]==dLOCKED)
21266 {
21267 if(usekey())
21268 {
21269 putdoor(scrollbuf,0,left,dUNLOCKED);
21270 tmpscr->door[2]=dUNLOCKED;
21271 setmapflag(si, mDOOR_LEFT);
21272
21273 if(di != 0xFFFF)
21274 setmapflag(di, mDOOR_RIGHT);
21275 sfx(WAV_DOOR);
21276 markBmap(-1);
21277 }
21278 else return;
21279 }
21280 else if(tmpscr->door[2]==dBOSS)
21281 {
21282 if(game->lvlitems[dlevel]&liBOSSKEY)
21283 {
21284 putdoor(scrollbuf,0,left,dOPENBOSS);
21285 tmpscr->door[2]=dOPENBOSS;
21286 setmapflag(si, mDOOR_LEFT);
21287
21288 if(di != 0xFFFF)
21289 setmapflag(di, mDOOR_RIGHT);
21290 sfx(WAV_DOOR);
21291 markBmap(-1);
21292 // Run Boss Key Script
21293 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21294 for ( int32_t q = 0; q < MAXITEMS; ++q )
21295 {
21296 if ( itemsbuf[q].family == itype_bosskey )
21297 {
21298 key_item = q; break;
21299 }
21300 }
21301 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
21302 {
21303 ri = &(itemScriptData[key_item]);
21304 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
21305 ri->Clear();
21306 item_doscript[key_item] = 1;
21307 itemscriptInitialised[key_item] = 0;
21308 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
21309 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
21310 }
21311 }
21312 else return;
21313 }
21314 }
21315 }
21316
21317
21318 //right
21319 if ( ( y > 72 && y < 88 ) && x >= 208 )
21320 //!( (y<=72||y>=88) && x<206 ) )
21321 //y<=72||y>=88):y!=80) || x<208)
21322 {
21323 if ( dir == right || dir == r_up || dir == r_down ) //|| Right() || ( Down()&&Right() ) || ( Up()&&Right()))
21324 {
21325 di = nextscr(right);
21326 if(tmpscr->door[right]==dLOCKED)
21327 {
21328 if(usekey())
21329 {
21330 putdoor(scrollbuf,0,right,dUNLOCKED);
21331 tmpscr->door[3]=dUNLOCKED;
21332 setmapflag(si, mDOOR_RIGHT);
21333
21334 if(di != 0xFFFF)
21335 setmapflag(di, mDOOR_LEFT);
21336 sfx(WAV_DOOR);
21337 markBmap(-1);
21338 }
21339 else return;
21340 }
21341 else if(tmpscr->door[right]==dBOSS)
21342 {
21343 if(game->lvlitems[dlevel]&liBOSSKEY)
21344 {
21345 putdoor(scrollbuf,0,right,dOPENBOSS);
21346 tmpscr->door[3]=dOPENBOSS;
21347 setmapflag(si, mDOOR_RIGHT);
21348
21349 if(di != 0xFFFF)
21350 setmapflag(di, mDOOR_LEFT);
21351 sfx(WAV_DOOR);
21352 markBmap(-1);
21353 // Run Boss Key Script
21354 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21355 for ( int32_t q = 0; q < MAXITEMS; ++q )
21356 {
21357 if ( itemsbuf[q].family == itype_bosskey )
21358 {
21359 key_item = q; break;
21360 }
21361 }
21362 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
21363 {
21364 ri = &(itemScriptData[key_item]);
21365 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
21366 ri->Clear();
21367 item_doscript[key_item] = 1;
21368 itemscriptInitialised[key_item] = 0;
21369 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
21370 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
21371 }
21372 }
21373 else return;
21374 }
21375
21376 }
21377 }
21378 }
21379 else
21380 {
21381 //orthogonal movement
21382 //Up door
21383
4/4
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 746 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 118 times.
943 if ( y<=32 && x == 120 )
21384 //!( y>32 && (x!=120) ))
21385 {
21386
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 1 times.
118 switch ( dir )
21387 {
21388 case up:
21389 case r_up:
21390 case l_up:
21391 {
21392 117 di = nextscr(up);
21393
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 26 times.
117 if(tmpscr->door[0]==dLOCKED)
21394 {
21395
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 3 times.
91 if(usekey())
21396 {
21397 88 putdoor(scrollbuf,0,up,dUNLOCKED);
21398 88 tmpscr->door[0]=dUNLOCKED;
21399 88 setmapflag(si, mDOOR_UP);
21400
21401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(di != 0xFFFF)
21402 88 setmapflag(di, mDOOR_DOWN);
21403 88 sfx(WAV_DOOR);
21404 88 markBmap(-1);
21405 88 }
21406 3 else return;
21407 88 }
21408
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 15 times.
26 else if(tmpscr->door[0]==dBOSS)
21409 {
21410
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1 times.
15 if(game->lvlitems[dlevel]&liBOSSKEY)
21411 {
21412 14 putdoor(scrollbuf,0,up,dOPENBOSS);
21413 14 tmpscr->door[0]=dOPENBOSS;
21414 14 setmapflag(si, mDOOR_UP);
21415
21416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(di != 0xFFFF)
21417 14 setmapflag(di, mDOOR_DOWN);
21418 14 sfx(WAV_DOOR);
21419 14 markBmap(-1);
21420 // Run Boss Key Script
21421 14 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 952 times.
952 for ( int32_t q = 0; q < MAXITEMS; ++q )
21423 {
21424
2/2
✓ Branch 0 taken 938 times.
✓ Branch 1 taken 14 times.
952 if ( itemsbuf[q].family == itype_bosskey )
21425 {
21426 14 key_item = q; break;
21427 }
21428 938 }
21429
2/8
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
21430 {
21431 ri = &(itemScriptData[key_item]);
21432 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
21433 ri->Clear();
21434 item_doscript[key_item] = 1;
21435 itemscriptInitialised[key_item] = 0;
21436 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
21437 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
21438 }
21439 14 }
21440 1 else return;
21441 14 }
21442 113 break;
21443 }
21444 1 default: break;
21445
21446 }
21447 114 }
21448 //Down
21449
4/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 820 times.
✓ Branch 2 taken 81 times.
✓ Branch 3 taken 38 times.
939 if ( y >= 128 && x == 120 )
21450 //!(y<128 && (x!=120) ) )
21451 {
21452
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 3 times.
38 switch(dir)
21453 {
21454 case down:
21455 case l_down:
21456 case r_down:
21457 {
21458 35 di = nextscr(down);
21459
21460
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 11 times.
35 if(tmpscr->door[1]==dLOCKED)
21461 {
21462
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if(usekey())
21463 {
21464 23 putdoor(scrollbuf,0,down,dUNLOCKED);
21465 23 tmpscr->door[1]=dUNLOCKED;
21466 23 setmapflag(si, mDOOR_DOWN);
21467
21468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(di != 0xFFFF)
21469 23 setmapflag(di, mDOOR_UP);
21470 23 sfx(WAV_DOOR);
21471 23 markBmap(-1);
21472 23 }
21473 1 else return;
21474 23 }
21475
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
11 else if(tmpscr->door[1]==dBOSS)
21476 {
21477
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 if(game->lvlitems[dlevel]&liBOSSKEY)
21478 {
21479 4 putdoor(scrollbuf,0,down,dOPENBOSS);
21480 4 tmpscr->door[1]=dOPENBOSS;
21481 4 setmapflag(si, mDOOR_DOWN);
21482
21483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(di != 0xFFFF)
21484 4 setmapflag(di, mDOOR_UP);
21485 4 sfx(WAV_DOOR);
21486 4 markBmap(-1);
21487 // Run Boss Key Script
21488 4 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 272 times.
272 for ( int32_t q = 0; q < MAXITEMS; ++q )
21490 {
21491
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 4 times.
272 if ( itemsbuf[q].family == itype_bosskey )
21492 {
21493 4 key_item = q; break;
21494 }
21495 268 }
21496
2/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
21497 {
21498 ri = &(itemScriptData[key_item]);
21499 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
21500 ri->Clear();
21501 item_doscript[key_item] = 1;
21502 itemscriptInitialised[key_item] = 0;
21503 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
21504 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
21505 }
21506 4 }
21507 1 else return;
21508 4 }
21509 33 break;
21510 }
21511 3 default: break;
21512 }
21513 36 }
21514 //left
21515
4/4
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 749 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 58 times.
937 if ( y == 80 && x <= 32 )
21516 //!( (y!=80) && x>32 ) )
21517 {
21518
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 9 times.
58 switch(dir)
21519 {
21520 case left:
21521 case l_up:
21522 case l_down:
21523 {
21524 49 di = nextscr(left);
21525
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 14 times.
49 if(tmpscr->door[2]==dLOCKED)
21526 {
21527
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 2 times.
35 if(usekey())
21528 {
21529 33 putdoor(scrollbuf,0,left,dUNLOCKED);
21530 33 tmpscr->door[2]=dUNLOCKED;
21531 33 setmapflag(si, mDOOR_LEFT);
21532
21533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(di != 0xFFFF)
21534 33 setmapflag(di, mDOOR_RIGHT);
21535 33 sfx(WAV_DOOR);
21536 33 markBmap(-1);
21537 33 }
21538 2 else return;
21539 33 }
21540
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 5 times.
14 else if(tmpscr->door[2]==dBOSS)
21541 {
21542
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 if(game->lvlitems[dlevel]&liBOSSKEY)
21543 {
21544 4 putdoor(scrollbuf,0,left,dOPENBOSS);
21545 4 tmpscr->door[2]=dOPENBOSS;
21546 4 setmapflag(si, mDOOR_LEFT);
21547
21548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(di != 0xFFFF)
21549 4 setmapflag(di, mDOOR_RIGHT);
21550 4 sfx(WAV_DOOR);
21551 4 markBmap(-1);
21552 // Run Boss Key Script
21553 4 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 272 times.
272 for ( int32_t q = 0; q < MAXITEMS; ++q )
21555 {
21556
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 4 times.
272 if ( itemsbuf[q].family == itype_bosskey )
21557 {
21558 4 key_item = q; break;
21559 }
21560 268 }
21561
2/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
21562 {
21563 ri = &(itemScriptData[key_item]);
21564 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
21565 ri->Clear();
21566 item_doscript[key_item] = 1;
21567 itemscriptInitialised[key_item] = 0;
21568 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
21569 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
21570 }
21571 4 }
21572 1 else return;
21573 4 }
21574
21575 46 break;
21576
21577 }
21578 9 default: break;
21579 }
21580 55 }
21581 //right
21582
4/4
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 749 times.
✓ Branch 2 taken 112 times.
✓ Branch 3 taken 73 times.
934 if ( y == 80 && x >= 208 )
21583 //!((y!=80) && x<208 ) )
21584 {
21585
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 4 times.
73 switch(dir)
21586 {
21587 case right:
21588 case r_down:
21589 case r_up:
21590 {
21591 69 di = nextscr(right);
21592
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 19 times.
69 if(tmpscr->door[3]==dLOCKED)
21593 {
21594
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 4 times.
50 if(usekey())
21595 {
21596 46 putdoor(scrollbuf,0,right,dUNLOCKED);
21597 46 tmpscr->door[3]=dUNLOCKED;
21598 46 setmapflag(si, mDOOR_RIGHT);
21599
21600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if(di != 0xFFFF)
21601 46 setmapflag(di, mDOOR_LEFT);
21602 46 sfx(WAV_DOOR);
21603 46 markBmap(-1);
21604 46 }
21605 4 else return;
21606 46 }
21607
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 8 times.
19 else if(tmpscr->door[3]==dBOSS)
21608 {
21609
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if(game->lvlitems[dlevel]&liBOSSKEY)
21610 {
21611 7 putdoor(scrollbuf,0,right,dOPENBOSS);
21612 7 tmpscr->door[3]=dOPENBOSS;
21613 7 setmapflag(si, mDOOR_RIGHT);
21614
21615
21616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(di != 0xFFFF)
21617 7 setmapflag(di, mDOOR_LEFT);
21618 7 sfx(WAV_DOOR);
21619 7 markBmap(-1);
21620 // Run Boss Key Script
21621 7 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 476 times.
476 for ( int32_t q = 0; q < MAXITEMS; ++q )
21623 {
21624
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 7 times.
476 if ( itemsbuf[q].family == itype_bosskey )
21625 {
21626 7 key_item = q; break;
21627 }
21628 469 }
21629
2/8
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) ) //
21630 {
21631 ri = &(itemScriptData[key_item]);
21632 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
21633 ri->Clear();
21634 item_doscript[key_item] = 1;
21635 itemscriptInitialised[key_item] = 0;
21636 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
21637 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
21638 }
21639
21640 7 }
21641 1 else return;
21642 7 }
21643
21644
21645 64 break;
21646 }
21647 4 default: break;
21648
21649 }
21650 68 }
21651 }
21652 6409244 }
21653
21654 6409244 void HeroClass::checkswordtap()
21655 {
21656
6/6
✓ Branch 0 taken 3024877 times.
✓ Branch 1 taken 3384367 times.
✓ Branch 2 taken 1913 times.
✓ Branch 3 taken 3022964 times.
✓ Branch 4 taken 1902 times.
✓ Branch 5 taken 11 times.
6409244 if(attack!=wSword || charging<=0 || pushing<8) return;
21657
21658 11 int32_t bx=x;
21659 11 int32_t by=y+8;
21660
21661
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
11 switch(dir)
21662 {
21663 case up:
21664
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!Up()) return;
21665
21666 11 by-=16;
21667 11 break;
21668
21669 case down:
21670 if(!Down()) return;
21671
21672 by+=16;
21673 bx+=8;
21674 break;
21675
21676 case left:
21677 if(!Left()) return;
21678
21679 bx-=16;
21680 by+=8;
21681 break;
21682
21683 case right:
21684 if(!Right()) return;
21685
21686 bx+=16;
21687 by+=8;
21688 break;
21689 }
21690
21691
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
11 if(!_walkflag(bx,by,0,SWITCHBLOCK_STATE)) return;
21692
21693 11 attackclk=SWORDTAPFRAME;
21694 11 pushing=-8; //16 frames between taps
21695 11 tapping=true;
21696
21697 11 int32_t type = COMBOTYPE(bx,by);
21698
21699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!isCuttableType(type))
21700 {
21701
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
22 bool hollow = (MAPFLAG(bx,by) == mfBOMB || MAPCOMBOFLAG(bx,by) == mfBOMB ||
21702
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 MAPFLAG(bx,by) == mfSBOMB || MAPCOMBOFLAG(bx,by) == mfSBOMB);
21703
21704 // Layers
21705
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 11 times.
77 for(int32_t i=0; i < 6; i++)
21706
3/6
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
132 hollow = (hollow || MAPFLAG2(i,bx,by) == mfBOMB || MAPCOMBOFLAG2(i,bx,by) == mfBOMB ||
21707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 MAPFLAG2(i,bx,by) == mfSBOMB || MAPCOMBOFLAG2(i,bx,by) == mfSBOMB);
21708
21709
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t i=0; i<4; i++)
21710
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44 if(tmpscr->door[i]==dBOMB && i==dir)
21711 switch(i)
21712 {
21713 case up:
21714 case down:
21715 if(bx>=112 && bx<144 && (by>=144 || by<=32)) hollow=true;
21716
21717 break;
21718
21719 case left:
21720 case right:
21721 if(by>=72 && by<104 && (bx>=224 || bx<=32)) hollow=true;
21722
21723 break;
21724 }
21725
21726 11 sfx(hollow ? WAV_ZN1TAP2 : WAV_ZN1TAP,pan(x.getInt()));
21727 11 }
21728
21729 6409244 }
21730
21731 19620 void HeroClass::fairycircle(int32_t type)
21732 {
21733
2/2
✓ Branch 0 taken 16361 times.
✓ Branch 1 taken 3259 times.
19620 if(fairyclk==0)
21734 {
21735
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3259 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3259 switch(type)
21736 {
21737 case REFILL_LIFE:
21738
2/2
✓ Branch 0 taken 3156 times.
✓ Branch 1 taken 103 times.
3259 if(didstuff&did_fairy) return;
21739
21740 103 didstuff|=did_fairy;
21741 103 break;
21742
21743 case REFILL_MAGIC:
21744 if(didstuff&did_magic) return;
21745
21746 didstuff|=did_magic;
21747 break;
21748
21749 case REFILL_ALL:
21750 if(didstuff&did_all) return;
21751
21752 didstuff|=did_all;
21753 }
21754
21755 103 refill_what=type;
21756 103 refill_why=REFILL_FAIRY;
21757 103 StartRefill(type);
21758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
21759 103 else {action=freeze; FFCore.setHeroAction(freeze);}
21760 103 holdclk=0;
21761 103 hopclk=0;
21762 103 }
21763
21764 16464 ++fairyclk;
21765
21766
2/2
✓ Branch 0 taken 8121 times.
✓ Branch 1 taken 8343 times.
16464 if(refilling!=REFILL_FAIRYDONE)
21767 {
21768
2/2
✓ Branch 0 taken 8018 times.
✓ Branch 1 taken 103 times.
8121 if(!refill())
21769 103 refilling=REFILL_FAIRYDONE;
21770 8121 }
21771
21772
2/2
✓ Branch 0 taken 8240 times.
✓ Branch 1 taken 103 times.
8343 else if(++holdclk>80)
21773 {
21774 103 reset_swordcharge();
21775 103 attackclk=0;
21776 103 action=none; FFCore.setHeroAction(none);
21777 103 fairyclk=0;
21778 103 holdclk=0;
21779 103 refill_why = 0;
21780 103 refilling=REFILL_NONE;
21781 103 map_bkgsfx(true);
21782 103 }
21783 19620 }
21784
21785 643596 int32_t touchcombo(int32_t x,int32_t y)
21786 {
21787
2/2
✓ Branch 0 taken 1287192 times.
✓ Branch 1 taken 643596 times.
1930788 for (int32_t i = 0; i <= 1; ++i)
21788 {
21789
2/2
✓ Branch 0 taken 1081507 times.
✓ Branch 1 taken 205685 times.
1287192 if(tmpscr2[i].valid!=0)
21790 {
21791
2/2
✓ Branch 0 taken 197733 times.
✓ Branch 1 taken 7952 times.
205685 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
21792 {
21793
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 197733 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
197733 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && !_walkflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
21794 197733 }
21795 else
21796 {
21797
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7952 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7952 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && _effectflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
21798 }
21799 205685 }
21800 1287192 }
21801
2/2
✓ Branch 0 taken 642182 times.
✓ Branch 1 taken 1414 times.
643596 if (!_effectflag(x,y,1, -1)) return 0;
21802 642182 newcombo const& cmb = combobuf[MAPCOMBO(x,y)];
21803
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 642134 times.
642182 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
21804 48 return 0;
21805
3/3
✓ Branch 0 taken 2842 times.
✓ Branch 1 taken 637673 times.
✓ Branch 2 taken 1619 times.
642134 switch(cmb.type)
21806 {
21807 case cBSGRAVE:
21808 case cGRAVE:
21809
3/4
✓ Branch 0 taken 1913 times.
✓ Branch 1 taken 929 times.
✓ Branch 2 taken 1913 times.
✗ Branch 3 not taken.
2842 if(MAPFLAG(x,y)||MAPCOMBOFLAG(x,y)) //!DIMITODO: all flags break graves, not just push flags
21810 {
21811 929 break;
21812 }
21813
21814 [[fallthrough]];
21815 case cARMOS:
21816 {
21817 3532 return cmb.type;
21818 }
21819 }
21820
21821 638602 return 0;
21822 643596 }
21823
21824 //static int32_t COMBOX(int32_t pos) { return ((pos)%16*16); }
21825 //static int32_t COMBOY(int32_t pos) { return ((pos)&0xF0); }
21826
21827 static int32_t GridX(int32_t x)
21828 {
21829 return (x >> 4) << 4;
21830 }
21831
21832 //Snaps 'y' to the combo grid
21833 //Equivalent to calling ComboY(ComboAt(foo,y));
21834 static int32_t GridY(int32_t y)
21835 {
21836 return (y >> 4) << 4;
21837 }
21838
21839 30 int32_t grabComboFromPos(int32_t pos, int32_t type)
21840 {
21841
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 for(int32_t lyr = 6; lyr > -1; --lyr)
21842 {
21843 210 int32_t id = FFCore.tempScreens[lyr]->data[pos];
21844
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 180 times.
210 if(combobuf[id].type == type)
21845 30 return id;
21846 180 }
21847 return -1;
21848 30 }
21849
21850 static int32_t typeMap[176];
21851 static int32_t istrig[176];
21852 static const int32_t SPTYPE_SOLID = -1;
21853 #define SP_VISITED 0x1
21854 #define SPFLAG(dir) (0x2<<dir)
21855 #define BEAM_AGE_LIMIT 32
21856 1234 void HeroClass::handleBeam(byte* grid, size_t age, byte spotdir, int32_t curpos, byte set, bool block, bool refl)
21857 {
21858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 int32_t trigflag = set ? (1 << (set-1)) : ~0;
21859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 if(spotdir > 3) return; //invalid dir
21860 1234 bool doAge = true;
21861 1234 byte f = 0;
21862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13668 times.
13668 while(unsigned(curpos) < 176)
21863 {
21864 13668 bool block_light = false;
21865 13668 f = SPFLAG(spotdir);
21866
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 13341 times.
13668 if((grid[curpos] & f) != f)
21867 {
21868 13341 grid[curpos] |= f;
21869 13341 istrig[curpos] |= trigflag;
21870 13341 doAge = false;
21871 13341 age = 0;
21872 13341 }
21873
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 652 times.
✓ Branch 3 taken 12657 times.
✓ Branch 4 taken 183 times.
13668 switch(spotdir)
21874 {
21875 case up:
21876 176 curpos -= 0x10;
21877 176 break;
21878 case down:
21879 652 curpos += 0x10;
21880 652 break;
21881 case left:
21882
1/2
✓ Branch 0 taken 12657 times.
✗ Branch 1 not taken.
12657 if(!(curpos%0x10))
21883 curpos = -1;
21884 12657 else --curpos;
21885 12657 break;
21886 case right:
21887 183 ++curpos;
21888
1/2
✓ Branch 0 taken 183 times.
✗ Branch 1 not taken.
183 if(!(curpos%0x10))
21889 curpos = -1;
21890 183 break;
21891 }
21892
1/2
✓ Branch 0 taken 13668 times.
✗ Branch 1 not taken.
13668 if(unsigned(curpos) >= 176) break;
21893
2/2
✓ Branch 0 taken 1228 times.
✓ Branch 1 taken 12440 times.
13668 switch(typeMap[curpos])
21894 {
21895 case SPTYPE_SOLID: case cBLOCKALL:
21896 1228 curpos = -1;
21897 1228 break;
21898 }
21899
3/6
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 13371 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 297 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13668 if((curpos==COMBOPOS(x.getInt()+8,y.getInt()+8)) && block && (spotdir == oppositeDir[dir]))
21900 curpos = -1;
21901
2/2
✓ Branch 0 taken 12440 times.
✓ Branch 1 taken 1228 times.
13668 if(unsigned(curpos) >= 176) break;
21902
21903 12440 f = SPFLAG(oppositeDir[spotdir]);
21904
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 12113 times.
12440 if((grid[curpos] & f) != f)
21905 {
21906 12113 grid[curpos] |= f;
21907 12113 istrig[curpos] |= trigflag;
21908 12113 doAge = false;
21909 12113 age = 0;
21910 12113 }
21911
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 12113 times.
12440 if(doAge)
21912 {
21913
2/2
✓ Branch 0 taken 321 times.
✓ Branch 1 taken 6 times.
327 if(++age > BEAM_AGE_LIMIT)
21914 6 break;
21915 321 }
21916 12113 else doAge = true;
21917
21918
3/4
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 12137 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 297 times.
12434 if(curpos==COMBOPOS(x.getInt()+8,y.getInt() +8) && refl)
21919 297 spotdir = dir;
21920
2/7
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 12107 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
12137 else switch(typeMap[curpos])
21921 {
21922 case cLIGHTTARGET:
21923
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(combobuf[grabComboFromPos(curpos, cLIGHTTARGET)].usrflags&cflag3) //Blocks light
21924 return;
21925 case cMIRROR:
21926 30 spotdir = oppositeDir[spotdir];
21927 30 break;
21928 case cMIRRORSLASH:
21929 switch(spotdir)
21930 {
21931 case up:
21932 spotdir = right; break;
21933 case right:
21934 spotdir = up; break;
21935 case down:
21936 spotdir = left; break;
21937 case left:
21938 spotdir = down; break;
21939 }
21940 break;
21941 case cMIRRORBACKSLASH:
21942 switch(spotdir)
21943 {
21944 case up:
21945 spotdir = left; break;
21946 case left:
21947 spotdir = up; break;
21948 case down:
21949 spotdir = right; break;
21950 case right:
21951 spotdir = down; break;
21952 }
21953 break;
21954 case cMAGICPRISM:
21955 for(byte d = 0; d < 4; ++d)
21956 {
21957 if(d == oppositeDir[spotdir]) continue;
21958 handleBeam(grid, age, d, curpos, set, block, refl);
21959 }
21960 return;
21961 case cMAGICPRISM4:
21962 for(byte d = 0; d < 4; ++d)
21963 {
21964 handleBeam(grid, age, d, curpos, set, block, refl);
21965 }
21966 return;
21967 }
21968 }
21969 1234 }
21970
21971 6419565 void HeroClass::handleSpotlights()
21972 {
21973 typedef byte spot_t;
21974 //Store each different tile/color as grids
21975 6419565 std::map<int32_t, spot_t*> maps;
21976
1/2
✓ Branch 0 taken 6419565 times.
✗ Branch 1 not taken.
6419565 int32_t shieldid = getCurrentShield(false);
21977
2/2
✓ Branch 0 taken 5877540 times.
✓ Branch 1 taken 542025 times.
6419565 bool refl = shieldid > -1 && (itemsbuf[shieldid].misc2 & shLIGHTBEAM);
21978
4/4
✓ Branch 0 taken 6409475 times.
✓ Branch 1 taken 10090 times.
✓ Branch 2 taken 542025 times.
✓ Branch 3 taken 5867450 times.
6419565 bool block = !refl && shieldid > -1 && (itemsbuf[shieldid].misc1 & shLIGHTBEAM);
21979
3/6
✓ Branch 0 taken 6419565 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6419565 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6419565 times.
✗ Branch 5 not taken.
6419565 int32_t heropos = COMBOPOS(x.getInt()+8,y.getInt()+8);
21980 6419565 memset(istrig, 0, sizeof(istrig));
21981
1/2
✓ Branch 0 taken 6419565 times.
✗ Branch 1 not taken.
6419565 clear_bitmap(lightbeam_bmp);
21982
21983
2/2
✓ Branch 0 taken 1129843440 times.
✓ Branch 1 taken 6419565 times.
1136263005 for(size_t pos = 0; pos < 176; ++pos)
21984 {
21985 1129843440 typeMap[pos] = 0;
21986
2/2
✓ Branch 0 taken 1129629964 times.
✓ Branch 1 taken 7908863472 times.
9038493436 for(int32_t lyr = 6; lyr > -1; --lyr)
21987 {
21988 7908863472 newcombo const* cmb = &combobuf[FFCore.tempScreens[lyr]->data[pos]];
21989
3/3
✓ Branch 0 taken 209774 times.
✓ Branch 1 taken 7908649996 times.
✓ Branch 2 taken 3702 times.
7908863472 switch(cmb->type)
21990 {
21991 case cMIRROR: case cMIRRORSLASH: case cMIRRORBACKSLASH:
21992 case cMAGICPRISM: case cMAGICPRISM4:
21993 case cBLOCKALL: case cLIGHTTARGET:
21994 209774 typeMap[pos] = cmb->type;
21995 209774 break;
21996 case cGLASS:
21997 3702 typeMap[pos] = 0;
21998 3702 break;
21999 default:
22000 {
22001
4/4
✓ Branch 0 taken 3389276236 times.
✓ Branch 1 taken 4519373760 times.
✓ Branch 2 taken 2707446820 times.
✓ Branch 3 taken 681829416 times.
7908649996 if(lyr < 3 && (cmb->walk & 0xF))
22002 {
22003 681829416 typeMap[pos] = SPTYPE_SOLID;
22004 681829416 }
22005 7908649996 continue; //next layer
22006 }
22007 }
22008 213476 break; //hit a combo type
22009 }
22010 1129843440 }
22011
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 6419318 times.
6419565 if(unsigned(heropos) < 176)
22012 {
22013
2/2
✓ Branch 0 taken 627557 times.
✓ Branch 1 taken 5791761 times.
6419318 switch(typeMap[heropos])
22014 {
22015 case SPTYPE_SOLID: case cBLOCKALL:
22016 627557 heropos = -1; //Blocked from hitting player
22017 627557 }
22018 6419318 }
22019
22020
2/2
✓ Branch 0 taken 44936955 times.
✓ Branch 1 taken 6419565 times.
51356520 for(size_t layer = 0; layer < 7; ++layer)
22021 {
22022 44936955 mapscr* curlayer = FFCore.tempScreens[layer];
22023
2/2
✓ Branch 0 taken 7908904080 times.
✓ Branch 1 taken 44936955 times.
7953841035 for(size_t pos = 0; pos < 176; ++pos)
22024 {
22025 //For each spotlight combo on each layer...
22026 7908904080 newcombo const& cmb = combobuf[curlayer->data[pos]];
22027
2/2
✓ Branch 0 taken 7908902846 times.
✓ Branch 1 taken 1234 times.
7908904080 if(cmb.type == cSPOTLIGHT)
22028 {
22029 //Positive ID is a tile, negative is a color trio. 0 is nil in either case.
22030
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
2468 int32_t id = (cmb.usrflags&cflag1)
22031
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 ? std::max(0,cmb.attributes[0]/10000)|(cmb.attribytes[1]%12)<<24
22032 : -((cmb.attribytes[3]<<16)|(cmb.attribytes[2]<<8)|(cmb.attribytes[1]));
22033
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(!id) continue;
22034 // zprint2("ID = %ld\n", id);
22035 //Get the grid array for this tile/color
22036 spot_t* grid;
22037
2/4
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1234 times.
1234 if(maps[id])
22038 grid = maps[id];
22039 else
22040 {
22041
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 grid = new spot_t[176];
22042 1234 memset(grid, 0, sizeof(spot_t)*176);
22043
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 maps[id] = grid;
22044 }
22045 1234 byte spotdir = cmb.attribytes[0];
22046 1234 int32_t curpos = pos;
22047
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(spotdir > 3)
22048 {
22049 grid[curpos] |= SP_VISITED;
22050 istrig[curpos] |= cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
22051 }
22052
2/4
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1234 times.
✗ Branch 3 not taken.
1234 if(refl && curpos == heropos)
22053 {
22054 spotdir = dir;
22055 }
22056
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 handleBeam(grid, 0, spotdir, curpos, cmb.attribytes[4], block, refl);
22057 1234 }
22058 7908904080 }
22059 44936955 }
22060
22061 6419565 lightbeam_present = !maps.empty();
22062
22063 //Draw visuals
22064
2/2
✓ Branch 0 taken 6419565 times.
✓ Branch 1 taken 1234 times.
6420799 for(auto it = maps.begin(); it != maps.end();)
22065 {
22066 1234 int32_t id = it->first;
22067 1234 spot_t* grid = it->second;
22068 //
22069 enum {t_gr, t_up, t_down, t_left, t_right, t_uleft, t_uright, t_dleft, t_dright, t_vert, t_horz, t_notup, t_notdown, t_notleft, t_notright, t_all, t_max };
22070 1234 int32_t tile = (id&0xFFFFFF);
22071 1234 int32_t cs = (id>>24);
22072 1234 byte c_inner = ((-id)&0x0000FF);
22073 1234 byte c_middle = ((-id)&0x00FF00)>>8;
22074 1234 byte c_outter = ((-id)&0xFF0000)>>16;
22075 //{ Setup color bitmap
22076 1234 BITMAP* cbmp = NULL;
22077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 if(id < 0)
22078 {
22079 //zprint2("Creating with colors: %02X,%02X,%02X\n", c_inner, c_middle, c_outter);
22080 cbmp = create_bitmap_ex(8, 16*t_max, 16);
22081 clear_bitmap(cbmp);
22082 for(size_t q = 1; q < t_max; ++q)
22083 {
22084 circlefill(cbmp, 16*q+8, 8, 3, c_outter);
22085 circlefill(cbmp, 16*q+7, 8, 3, c_outter);
22086 circlefill(cbmp, 16*q+8, 7, 3, c_outter);
22087 circlefill(cbmp, 16*q+7, 7, 3, c_outter);
22088 circlefill(cbmp, 16*q+8, 8, 1, c_middle);
22089 circlefill(cbmp, 16*q+7, 8, 1, c_middle);
22090 circlefill(cbmp, 16*q+8, 7, 1, c_middle);
22091 circlefill(cbmp, 16*q+7, 7, 1, c_middle);
22092 circlefill(cbmp, 16*q+8, 8, 0, c_inner);
22093 circlefill(cbmp, 16*q+7, 8, 0, c_inner);
22094 circlefill(cbmp, 16*q+8, 7, 0, c_inner);
22095 circlefill(cbmp, 16*q+7, 7, 0, c_inner);
22096 }
22097 //t_gr
22098 circlefill(cbmp, 16*t_gr+8, 8, 7, c_outter);
22099 circlefill(cbmp, 16*t_gr+7, 8, 7, c_outter);
22100 circlefill(cbmp, 16*t_gr+8, 7, 7, c_outter);
22101 circlefill(cbmp, 16*t_gr+7, 7, 7, c_outter);
22102 circlefill(cbmp, 16*t_gr+8, 8, 5, c_middle);
22103 circlefill(cbmp, 16*t_gr+7, 8, 5, c_middle);
22104 circlefill(cbmp, 16*t_gr+8, 7, 5, c_middle);
22105 circlefill(cbmp, 16*t_gr+7, 7, 5, c_middle);
22106 circlefill(cbmp, 16*t_gr+8, 8, 3, c_inner);
22107 circlefill(cbmp, 16*t_gr+7, 8, 3, c_inner);
22108 circlefill(cbmp, 16*t_gr+8, 7, 3, c_inner);
22109 circlefill(cbmp, 16*t_gr+7, 7, 3, c_inner);
22110 //t_up
22111 rectfill(cbmp, 16*t_up+4, 0, 16*t_up+11, 7, c_outter);
22112 rectfill(cbmp, 16*t_up+6, 0, 16*t_up+9, 7, c_middle);
22113 rectfill(cbmp, 16*t_up+7, 0, 16*t_up+8, 7, c_inner);
22114 //t_down
22115 rectfill(cbmp, 16*t_down+4, 8, 16*t_down+11, 15, c_outter);
22116 rectfill(cbmp, 16*t_down+6, 8, 16*t_down+9, 15, c_middle);
22117 rectfill(cbmp, 16*t_down+7, 8, 16*t_down+8, 15, c_inner);
22118 //t_left
22119 rectfill(cbmp, 16*t_left, 4, 16*t_left+7, 11, c_outter);
22120 rectfill(cbmp, 16*t_left, 6, 16*t_left+7, 9, c_middle);
22121 rectfill(cbmp, 16*t_left, 7, 16*t_left+7, 8, c_inner);
22122 //t_right
22123 rectfill(cbmp, 16*t_right+8, 4, 16*t_right+15, 11, c_outter);
22124 rectfill(cbmp, 16*t_right+8, 6, 16*t_right+15, 9, c_middle);
22125 rectfill(cbmp, 16*t_right+8, 7, 16*t_right+15, 8, c_inner);
22126 //t_uleft
22127 rectfill(cbmp, 16*t_uleft+4, 0, 16*t_uleft+11, 7, c_outter);
22128 rectfill(cbmp, 16*t_uleft, 4, 16*t_uleft+7, 11, c_outter);
22129 rectfill(cbmp, 16*t_uleft, 6, 16*t_uleft+7, 9, c_middle);
22130 rectfill(cbmp, 16*t_uleft+6, 0, 16*t_uleft+9, 7, c_middle);
22131 rectfill(cbmp, 16*t_uleft+7, 0, 16*t_uleft+8, 7, c_inner);
22132 rectfill(cbmp, 16*t_uleft, 7, 16*t_uleft+7, 8, c_inner);
22133 //t_uright
22134 rectfill(cbmp, 16*t_uright+4, 0, 16*t_uright+11, 7, c_outter);
22135 rectfill(cbmp, 16*t_uright+8, 4, 16*t_uright+15, 11, c_outter);
22136 rectfill(cbmp, 16*t_uright+8, 6, 16*t_uright+15, 9, c_middle);
22137 rectfill(cbmp, 16*t_uright+6, 0, 16*t_uright+9, 7, c_middle);
22138 rectfill(cbmp, 16*t_uright+7, 0, 16*t_uright+8, 7, c_inner);
22139 rectfill(cbmp, 16*t_uright+8, 7, 16*t_uright+15, 8, c_inner);
22140 //t_dleft
22141 rectfill(cbmp, 16*t_dleft+4, 8, 16*t_dleft+11, 15, c_outter);
22142 rectfill(cbmp, 16*t_dleft, 4, 16*t_dleft+7, 11, c_outter);
22143 rectfill(cbmp, 16*t_dleft, 6, 16*t_dleft+7, 9, c_middle);
22144 rectfill(cbmp, 16*t_dleft+6, 8, 16*t_dleft+9, 15, c_middle);
22145 rectfill(cbmp, 16*t_dleft+7, 8, 16*t_dleft+8, 15, c_inner);
22146 rectfill(cbmp, 16*t_dleft, 7, 16*t_dleft+7, 8, c_inner);
22147 //t_dright
22148 rectfill(cbmp, 16*t_dright+4, 8, 16*t_dright+11, 15, c_outter);
22149 rectfill(cbmp, 16*t_dright+8, 4, 16*t_dright+15, 11, c_outter);
22150 rectfill(cbmp, 16*t_dright+8, 6, 16*t_dright+15, 9, c_middle);
22151 rectfill(cbmp, 16*t_dright+6, 8, 16*t_dright+9, 15, c_middle);
22152 rectfill(cbmp, 16*t_dright+7, 8, 16*t_dright+8, 15, c_inner);
22153 rectfill(cbmp, 16*t_dright+8, 7, 16*t_dright+15, 8, c_inner);
22154 //t_vert
22155 rectfill(cbmp, 16*t_vert+4, 0, 16*t_vert+11, 15, c_outter);
22156 rectfill(cbmp, 16*t_vert+6, 0, 16*t_vert+9, 15, c_middle);
22157 rectfill(cbmp, 16*t_vert+7, 0, 16*t_vert+8, 15, c_inner);
22158 //t_horz
22159 rectfill(cbmp, 16*t_horz, 4, 16*t_horz+15, 11, c_outter);
22160 rectfill(cbmp, 16*t_horz, 6, 16*t_horz+15, 9, c_middle);
22161 rectfill(cbmp, 16*t_horz, 7, 16*t_horz+15, 8, c_inner);
22162 //t_notup
22163 rectfill(cbmp, 16*t_notup, 4, 16*t_notup+15, 11, c_outter);
22164 rectfill(cbmp, 16*t_notup+4, 8, 16*t_notup+11, 15, c_outter);
22165 rectfill(cbmp, 16*t_notup+6, 8, 16*t_notup+9, 15, c_middle);
22166 rectfill(cbmp, 16*t_notup, 6, 16*t_notup+15, 9, c_middle);
22167 rectfill(cbmp, 16*t_notup, 7, 16*t_notup+15, 8, c_inner);
22168 rectfill(cbmp, 16*t_notup+7, 8, 16*t_notup+8, 15, c_inner);
22169 //t_notdown
22170 rectfill(cbmp, 16*t_notdown, 4, 16*t_notdown+15, 11, c_outter);
22171 rectfill(cbmp, 16*t_notdown+4, 0, 16*t_notdown+11, 7, c_outter);
22172 rectfill(cbmp, 16*t_notdown+6, 0, 16*t_notdown+9, 7, c_middle);
22173 rectfill(cbmp, 16*t_notdown, 6, 16*t_notdown+15, 9, c_middle);
22174 rectfill(cbmp, 16*t_notdown, 7, 16*t_notdown+15, 8, c_inner);
22175 rectfill(cbmp, 16*t_notdown+7, 0, 16*t_notdown+8, 7, c_inner);
22176 //t_notleft
22177 rectfill(cbmp, 16*t_notleft+4, 0, 16*t_notleft+11, 15, c_outter);
22178 rectfill(cbmp, 16*t_notleft+8, 4, 16*t_notleft+15, 11, c_outter);
22179 rectfill(cbmp, 16*t_notleft+8, 6, 16*t_notleft+15, 9, c_middle);
22180 rectfill(cbmp, 16*t_notleft+6, 0, 16*t_notleft+9, 15, c_middle);
22181 rectfill(cbmp, 16*t_notleft+7, 0, 16*t_notleft+8, 15, c_inner);
22182 rectfill(cbmp, 16*t_notleft+8, 7, 16*t_notleft+15, 8, c_inner);
22183 //t_notright
22184 rectfill(cbmp, 16*t_notright+4, 0, 16*t_notright+11, 15, c_outter);
22185 rectfill(cbmp, 16*t_notright, 4, 16*t_notright+7, 11, c_outter);
22186 rectfill(cbmp, 16*t_notright, 6, 16*t_notright+7, 9, c_middle);
22187 rectfill(cbmp, 16*t_notright+6, 0, 16*t_notright+9, 15, c_middle);
22188 rectfill(cbmp, 16*t_notright+7, 0, 16*t_notright+8, 15, c_inner);
22189 rectfill(cbmp, 16*t_notright, 7, 16*t_notright+7, 8, c_inner);
22190 //t_all
22191 rectfill(cbmp, 16*t_all+4, 0, 16*t_all+11, 15, c_outter);
22192 rectfill(cbmp, 16*t_all, 4, 16*t_all+15, 11, c_outter);
22193 rectfill(cbmp, 16*t_all, 6, 16*t_all+15, 9, c_middle);
22194 rectfill(cbmp, 16*t_all+6, 0, 16*t_all+9, 15, c_middle);
22195 rectfill(cbmp, 16*t_all+7, 0, 16*t_all+8, 15, c_inner);
22196 rectfill(cbmp, 16*t_all, 7, 16*t_all+15, 8, c_inner);
22197 }
22198 //}
22199 //
22200
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 217184 times.
218418 for(size_t pos = 0; pos < 176; ++pos)
22201 {
22202 217184 int32_t offs = -1;
22203
8/17
✗ Branch 0 not taken.
✓ Branch 1 taken 203837 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1207 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 511 times.
✓ Branch 7 taken 11477 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 37 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 82 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
217184 switch(grid[pos]>>1)
22204 {
22205 203837 case 0: default:
22206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203837 times.
203837 if(grid[pos])
22207 {
22208 offs = t_gr;
22209 break;
22210 }
22211 203837 continue; //no draw this pos
22212 case 0b0001:
22213 6 offs = t_up;
22214 6 break;
22215 case 0b0010:
22216 offs = t_down;
22217 break;
22218 case 0b0100:
22219 1207 offs = t_left;
22220 1207 break;
22221 case 0b1000:
22222 27 offs = t_right;
22223 27 break;
22224 case 0b0011:
22225 511 offs = t_vert;
22226 511 break;
22227 case 0b1100:
22228 11477 offs = t_horz;
22229 11477 break;
22230 case 0b0101:
22231 offs = t_uleft;
22232 break;
22233 case 0b1001:
22234 37 offs = t_uright;
22235 37 break;
22236 case 0b0110:
22237 offs = t_dleft;
22238 break;
22239 case 0b1010:
22240 82 offs = t_dright;
22241 82 break;
22242 case 0b1110:
22243 offs = t_notup;
22244 break;
22245 case 0b1101:
22246 offs = t_notdown;
22247 break;
22248 case 0b1011:
22249 offs = t_notleft;
22250 break;
22251 case 0b0111:
22252 offs = t_notright;
22253 break;
22254 case 0b1111:
22255 offs = t_all;
22256 break;
22257 }
22258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13347 times.
13347 if(id > 0) //tile
22259 {
22260 //Draw 'tile' at 'pos'
22261
3/6
✓ Branch 0 taken 13347 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13347 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13347 times.
✗ Branch 5 not taken.
13347 overtile16(lightbeam_bmp, tile+offs, COMBOX(pos), COMBOY(pos), cs, 0);
22262 13347 }
22263 else //colors
22264 {
22265 masked_blit(cbmp, lightbeam_bmp, offs*16, 0, COMBOX(pos), COMBOY(pos), 16, 16);
22266 }
22267 13347 }
22268 //
22269
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1234 if(cbmp) destroy_bitmap(cbmp);
22270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 delete[] it->second;
22271
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 it = maps.erase(it);
22272 }
22273 //Check triggers
22274 6419565 bool hastrigs = false, istrigged = true;
22275
1/2
✓ Branch 0 taken 6419565 times.
✗ Branch 1 not taken.
6419565 bool alltrig = getmapflag(mLIGHTBEAM);
22276
2/2
✓ Branch 0 taken 44936955 times.
✓ Branch 1 taken 6419565 times.
51356520 for(size_t layer = 0; layer < 7; ++layer)
22277 {
22278 44936955 mapscr* curlayer = FFCore.tempScreens[layer];
22279
2/2
✓ Branch 0 taken 7908904080 times.
✓ Branch 1 taken 44936955 times.
7953841035 for(size_t pos = 0; pos < 176; ++pos)
22280 {
22281 7908904080 newcombo const* cmb = &combobuf[curlayer->data[pos]];
22282
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 7908902846 times.
7908904080 if(cmb->type == cLIGHTTARGET)
22283 {
22284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
22285 1234 hastrigs = true;
22286 1234 bool trigged = (istrig[pos]&trigflag);
22287
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(cmb->usrflags&cflag2) //Invert
22288 trigged = !trigged;
22289
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 985 times.
1234 if(cmb->usrflags&cflag1) //Solved Version
22290 {
22291
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if(!(alltrig || trigged)) //Revert
22292 {
22293 curlayer->data[pos] -= 1;
22294 istrigged = false;
22295 }
22296 249 }
22297 else //Unsolved version
22298 {
22299
3/4
✓ Branch 0 taken 985 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 984 times.
985 if(alltrig || trigged) //Light
22300 1 curlayer->data[pos] += 1;
22301 984 else istrigged = false;
22302 }
22303 1234 }
22304
2/2
✓ Branch 0 taken 7908899144 times.
✓ Branch 1 taken 3702 times.
7908902846 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
22305 {
22306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3702 times.
3702 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
22307 3702 bool trigged = (istrig[pos]&trigflag);
22308
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 3597 times.
✓ Branch 2 taken 3696 times.
✓ Branch 3 taken 6 times.
3702 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
22309 3597 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
22310 {
22311
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 do_trigger_combo(layer, pos);
22312 6 }
22313 3702 }
22314 7908904080 }
22315 44936955 }
22316
1/2
✓ Branch 0 taken 6419565 times.
✗ Branch 1 not taken.
6419565 word c = tmpscr->numFFC();
22317
2/2
✓ Branch 0 taken 6419565 times.
✓ Branch 1 taken 201309704 times.
207729269 for(word i=0; i<c; i++)
22318 {
22319 201309704 ffcdata& ffc = tmpscr->ffcs[i];
22320
1/2
✓ Branch 0 taken 201309704 times.
✗ Branch 1 not taken.
201309704 newcombo const* cmb = &combobuf[ffc.getData()];
22321
7/14
✓ Branch 0 taken 201309704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 201309704 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 201309704 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 201309704 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 201309704 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 201309704 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 201309704 times.
✗ Branch 13 not taken.
201309704 size_t pos = COMBOPOS(ffc.x+8, ffc.y+8);
22322
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 201308470 times.
201309704 if(cmb->type == cLIGHTTARGET)
22323 {
22324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
22325 1234 hastrigs = true;
22326 1234 bool trigged = (istrig[pos]&trigflag);
22327
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(cmb->usrflags&cflag2) //Invert
22328 trigged = !trigged;
22329
2/2
✓ Branch 0 taken 985 times.
✓ Branch 1 taken 249 times.
1234 if(cmb->usrflags&cflag1) //Solved Version
22330 {
22331
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if(!(alltrig || trigged)) //Revert
22332 {
22333 ffc.incData(-1);
22334 istrigged = false;
22335 }
22336 249 }
22337 else //Unsolved version
22338 {
22339
3/4
✓ Branch 0 taken 985 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 984 times.
985 if(alltrig || trigged) //Light
22340
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 ffc.incData(1);
22341 984 else istrigged = false;
22342 }
22343 1234 }
22344
2/2
✓ Branch 0 taken 201306002 times.
✓ Branch 1 taken 2468 times.
201308470 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
22345 {
22346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2468 times.
2468 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
22347 2468 bool trigged = (istrig[pos]&trigflag);
22348
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2406 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 2464 times.
2468 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
22349 2406 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
22350 {
22351
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 do_trigger_combo_ffc(i);
22352 4 }
22353 2468 }
22354 201309704 }
22355
6/6
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 6418331 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 984 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 249 times.
6419565 if(hastrigs && istrigged && !alltrig)
22356 {
22357
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 hidden_entrance(0,true,false,-7);
22358
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 sfx(tmpscr->secretsfx);
22359
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!(tmpscr->flags5&fTEMPSECRETS))
22360 {
22361
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 setmapflag(mSECRET);
22362
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 setmapflag(mLIGHTBEAM);
22363 1 }
22364 1 }
22365 6419565 }
22366
22367 6409244 void HeroClass::checktouchblk()
22368 {
22369
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 6395838 times.
6409244 if(toogam) return;
22370
22371
2/2
✓ Branch 0 taken 441774 times.
✓ Branch 1 taken 5954064 times.
6395838 if(!pushing)
22372 5954064 return;
22373
22374 441774 int32_t tdir = dir; //Bad hack #2. _L_, your welcome to fix this properly. ;)
22375
22376
4/4
✓ Branch 0 taken 441594 times.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 441498 times.
441774 if(charging > 0 || spins > 0) //if not I probably will at some point...
22377 {
22378
3/4
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
276 if(Up()&&Left())tdir = (charging%2)*2;
22379
3/4
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
276 else if(Up()&&Right())tdir = (charging%2)*3;
22380
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
276 else if(Down()&&Left())tdir = 1+(charging%2)*1;
22381
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
276 else if(Down()&&Right())tdir = 1+(charging%2)*2;
22382 else
22383 {
22384
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
276 if(Up())tdir=0;
22385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(Down())tdir=1;
22386
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(Left())tdir=2;
22387 else if(Right())tdir=3;
22388 }
22389 276 }
22390
22391 441774 int32_t tx=0,ty=-1;
22392
22393
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 109775 times.
✓ Branch 2 taken 93542 times.
✓ Branch 3 taken 114622 times.
✓ Branch 4 taken 123835 times.
441774 switch(tdir)
22394 {
22395 case up:
22396
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 109680 times.
109775 if(touchcombo(x,y+(bigHitbox?0:7)))
22397 {
22398 95 tx=x;
22399 95 ty=y+(bigHitbox?0:7);
22400 95 }
22401
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 109659 times.
109680 else if(touchcombo(x+8,y+(bigHitbox?0:7)))
22402 {
22403 21 tx=x+8;
22404 21 ty=y+(bigHitbox?0:7);
22405 21 }
22406
22407 109775 break;
22408
22409 case down:
22410
2/2
✓ Branch 0 taken 1400 times.
✓ Branch 1 taken 92142 times.
93542 if(touchcombo(x,y+16))
22411 {
22412 1400 tx=x;
22413 1400 ty=y+16;
22414 1400 }
22415
2/2
✓ Branch 0 taken 237 times.
✓ Branch 1 taken 91905 times.
92142 else if(touchcombo(x+8,y+16))
22416 {
22417 237 tx=x+8;
22418 237 ty=y+16;
22419 237 }
22420
22421 93542 break;
22422
22423 case left:
22424
2/2
✓ Branch 0 taken 113926 times.
✓ Branch 1 taken 696 times.
114622 if(touchcombo(x-1,y+15))
22425 {
22426 696 tx=x-1;
22427 696 ty=y+15;
22428 696 }
22429
22430 114622 break;
22431
22432 case right:
22433
2/2
✓ Branch 0 taken 122752 times.
✓ Branch 1 taken 1083 times.
123835 if(touchcombo(x+16,y+15))
22434 {
22435 1083 tx=x+16;
22436 1083 ty=y+15;
22437 1083 }
22438
22439 123835 break;
22440 }
22441
22442
2/2
✓ Branch 0 taken 438242 times.
✓ Branch 1 taken 3532 times.
441774 if(ty>=0)
22443 {
22444 3532 ty&=0xF0;
22445 3532 tx&=0xF0;
22446 3532 int32_t di = ty+(tx>>4);
22447
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3532 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3532 if((getAction() != hopping || isSideViewHero()))
22448 {
22449 3532 trigger_armos_grave(0, di, dir);
22450 3532 }
22451 3532 }
22452 6409244 }
22453
22454 int32_t HeroClass::nextcombo(int32_t cx, int32_t cy, int32_t cdir)
22455 {
22456 switch(cdir)
22457 {
22458 case up:
22459 cy-=16;
22460 break;
22461
22462 case down:
22463 cy+=16;
22464 break;
22465
22466 case left:
22467 cx-=16;
22468 break;
22469
22470 case right:
22471 cx+=16;
22472 break;
22473 }
22474
22475 // off the screen
22476 if(cx<0 || cy<0 || cx>255 || cy>175)
22477 {
22478 int32_t ns = nextscr(cdir);
22479
22480 if(ns==0xFFFF) return 0;
22481
22482 // want actual screen index, not game->maps[] index
22483 ns = (ns&127) + (ns>>7)*MAPSCRS;
22484
22485 switch(cdir)
22486 {
22487 case up:
22488 cy=160;
22489 break;
22490
22491 case down:
22492 cy=0;
22493 break;
22494
22495 case left:
22496 cx=240;
22497 break;
22498
22499 case right:
22500 cx=0;
22501 break;
22502 }
22503
22504 // from MAPCOMBO()
22505 int32_t cmb = (cy&0xF0)+(cx>>4);
22506
22507 if(cmb>175)
22508 return 0;
22509
22510 return TheMaps[ns].data[cmb]; // entire combo code
22511 }
22512
22513 return MAPCOMBO(cx,cy);
22514 }
22515
22516 8492 int32_t HeroClass::nextflag(int32_t cx, int32_t cy, int32_t cdir, bool comboflag)
22517 {
22518
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1729 times.
✓ Branch 2 taken 2005 times.
✓ Branch 3 taken 2441 times.
✓ Branch 4 taken 2317 times.
8492 switch(cdir)
22519 {
22520 case up:
22521 1729 cy-=16;
22522 1729 break;
22523
22524 case down:
22525 2005 cy+=16;
22526 2005 break;
22527
22528 case left:
22529 2441 cx-=16;
22530 2441 break;
22531
22532 case right:
22533 2317 cx+=16;
22534 2317 break;
22535 }
22536
22537 // off the screen
22538
8/8
✓ Branch 0 taken 8445 times.
✓ Branch 1 taken 47 times.
✓ Branch 2 taken 8386 times.
✓ Branch 3 taken 59 times.
✓ Branch 4 taken 8273 times.
✓ Branch 5 taken 113 times.
✓ Branch 6 taken 101 times.
✓ Branch 7 taken 8172 times.
8492 if(cx<0 || cy<0 || cx>255 || cy>175)
22539 {
22540 320 int32_t ns = nextscr(cdir);
22541
22542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 if(ns==0xFFFF) return 0;
22543
22544 // want actual screen index, not game->maps[] index
22545 320 ns = (ns&127) + (ns>>7)*MAPSCRS;
22546
22547
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 113 times.
320 switch(cdir)
22548 {
22549 case up:
22550 59 cy=160;
22551 59 break;
22552
22553 case down:
22554 101 cy=0;
22555 101 break;
22556
22557 case left:
22558 47 cx=240;
22559 47 break;
22560
22561 case right:
22562 113 cx=0;
22563 113 break;
22564 }
22565
22566 // from MAPCOMBO()
22567 320 int32_t cmb = (cy&0xF0)+(cx>>4);
22568
22569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 if(cmb>175)
22570 return 0;
22571
22572
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 255 times.
320 if(!comboflag)
22573 {
22574 255 return TheMaps[ns].sflag[cmb]; // flag
22575 }
22576 else
22577 {
22578 65 return combobuf[TheMaps[ns].data[cmb]].flag; // flag
22579 }
22580 }
22581
22582
2/2
✓ Branch 0 taken 2006 times.
✓ Branch 1 taken 6166 times.
8172 if(comboflag)
22583 {
22584 2006 return MAPCOMBOFLAG(cx,cy);
22585 }
22586
22587 6166 return MAPFLAG(cx,cy);
22588 8492 }
22589
22590 bool did_secret;
22591
22592 6409244 void HeroClass::checkspecial()
22593 {
22594 6409244 checktouchblk();
22595
22596 6409244 bool hasmainguy = hasMainGuy(); // calculate it once
22597
22598
4/4
✓ Branch 0 taken 6341859 times.
✓ Branch 1 taken 67385 times.
✓ Branch 2 taken 4087379 times.
✓ Branch 3 taken 2254480 times.
6409244 if(!(loaded_enemies && !hasmainguy))
22599 4154764 did_secret=false;
22600 else
22601 {
22602 // after beating enemies
22603
22604 // generic 'Enemies->' trigger
22605
2/2
✓ Branch 0 taken 15781360 times.
✓ Branch 1 taken 2254480 times.
18035840 for(auto lyr = 0; lyr < 7; ++lyr)
22606 {
22607
2/2
✓ Branch 0 taken 2777519360 times.
✓ Branch 1 taken 15781360 times.
2793300720 for(auto pos = 0; pos < 176; ++pos)
22608 {
22609 2777519360 newcombo const& cmb = combobuf[FFCore.tempScreens[lyr]->data[pos]];
22610
2/2
✓ Branch 0 taken 2777519357 times.
✓ Branch 1 taken 3 times.
2777519360 if(cmb.triggerflags[2] & combotriggerENEMIESKILLED)
22611 {
22612 3 do_trigger_combo(lyr,pos);
22613 3 }
22614 2777519360 }
22615 15781360 }
22616 2254480 word c = tmpscr->numFFC();
22617
2/2
✓ Branch 0 taken 69160059 times.
✓ Branch 1 taken 2254480 times.
71414539 for(word i=0; i<c; i++)
22618 {
22619 69160059 ffcdata& ffc = tmpscr->ffcs[i];
22620 69160059 newcombo const& cmb = combobuf[ffc.getData()];
22621
1/2
✓ Branch 0 taken 69160059 times.
✗ Branch 1 not taken.
69160059 if(cmb.triggerflags[2] & combotriggerENEMIESKILLED)
22622 {
22623 do_trigger_combo_ffc(i);
22624 }
22625 69160059 }
22626
1/2
✓ Branch 0 taken 2254480 times.
✗ Branch 1 not taken.
2254480 if(tmpscr->flags9 & fENEMY_WAVES)
22627 {
22628 hasmainguy = hasMainGuy(); //possibly un-beat the enemies (another 'wave'?)
22629 }
22630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2254480 times.
2254480 if(!hasmainguy)
22631 {
22632 // item
22633
2/2
✓ Branch 0 taken 2254028 times.
✓ Branch 1 taken 452 times.
2254480 if(hasitem&(4|2|1))
22634 {
22635 452 int32_t Item=tmpscr->item;
22636
22637 //if(getmapflag())
22638 // Item=0;
22639
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 452 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 452 times.
452 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
22640 {
22641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 452 times.
452 if(hasitem==1)
22642 452 sfx(WAV_CLEARED);
22643
22644
2/4
✓ Branch 0 taken 452 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 452 times.
✗ Branch 3 not taken.
904 items.add(new item((zfix)tmpscr->itemx,
22645
6/12
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 26 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 452 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 452 times.
✗ Branch 11 not taken.
452 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
22646
6/10
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 426 times.
✗ Branch 9 not taken.
452 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
22647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 452 times.
452 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
22648 452 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
22649 452 }
22650
22651 452 hasitem &= ~ (4|2|1);
22652 452 }
22653 // if room has traps, guys don't come back
22654
2/2
✓ Branch 0 taken 1154293760 times.
✓ Branch 1 taken 2254480 times.
1156548240 for(int32_t i=0; i<eMAXGUYS; i++)
22655 {
22656
4/4
✓ Branch 0 taken 33557998 times.
✓ Branch 1 taken 1120735762 times.
✓ Branch 2 taken 29106244 times.
✓ Branch 3 taken 4451754 times.
1154293760 if(guysbuf[i].family==eeTRAP&&guysbuf[i].misc2)
22657
4/4
✓ Branch 0 taken 22637 times.
✓ Branch 1 taken 4429117 times.
✓ Branch 2 taken 22611 times.
✓ Branch 3 taken 26 times.
4451780 if(guys.idCount(i) && !getmapflag(mTMPNORET))
22658 26 setmapflag(mTMPNORET);
22659 1154293760 }
22660 // clear enemies and open secret
22661
4/4
✓ Branch 0 taken 2138441 times.
✓ Branch 1 taken 116039 times.
✓ Branch 2 taken 2137990 times.
✓ Branch 3 taken 451 times.
2254480 if(!did_secret && (tmpscr->flags2&fCLEARSECRET))
22662 {
22663 451 bool only16_31 = get_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31)?true:false;
22664 451 hidden_entrance(0,true,only16_31,-2);
22665
22666
4/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 427 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 19 times.
451 if(tmpscr->flags4&fENEMYSCRTPERM && canPermSecret())
22667 {
22668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
22669 19 }
22670
22671 451 sfx(tmpscr->secretsfx);
22672 451 did_secret=true;
22673 451 }
22674 2254480 }
22675 }
22676
22677 // doors
22678 6409244 bool has_shutter = false;
22679
2/2
✓ Branch 0 taken 4988453 times.
✓ Branch 1 taken 23039188 times.
28027641 for(int32_t i=0; i<4; i++)
22680
2/2
✓ Branch 0 taken 21618397 times.
✓ Branch 1 taken 1420791 times.
23039188 if(tmpscr->door[i]==dSHUTTER)
22681 {
22682 1420791 has_shutter = true;
22683
4/4
✓ Branch 0 taken 1393331 times.
✓ Branch 1 taken 27460 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 1392416 times.
1420791 if(opendoors==0 && loaded_enemies)
22684 {
22685
4/4
✓ Branch 0 taken 1155712 times.
✓ Branch 1 taken 236704 times.
✓ Branch 2 taken 1154083 times.
✓ Branch 3 taken 1629 times.
1392416 if(!(tmpscr->flags&fSHUTTERS) && !hasmainguy)
22686 1629 opendoors=12;
22687 1392416 }
22688
2/2
✓ Branch 0 taken 22475 times.
✓ Branch 1 taken 5900 times.
28375 else if(opendoors<0)
22689 5900 ++opendoors;
22690
2/2
✓ Branch 0 taken 20594 times.
✓ Branch 1 taken 1881 times.
22475 else if((--opendoors)==0)
22691 1881 openshutters();
22692
22693 1420791 break;
22694 }
22695
10/10
✓ Branch 0 taken 4988453 times.
✓ Branch 1 taken 1420791 times.
✓ Branch 2 taken 4881327 times.
✓ Branch 3 taken 107126 times.
✓ Branch 4 taken 4818619 times.
✓ Branch 5 taken 62708 times.
✓ Branch 6 taken 4761837 times.
✓ Branch 7 taken 56782 times.
✓ Branch 8 taken 2700954 times.
✓ Branch 9 taken 2060883 times.
6409244 if(!has_shutter && !opendoors && loaded_enemies && !(tmpscr->flags&fSHUTTERS) && !hasmainguy)
22696 {
22697 2060883 openshutters();
22698 2060883 }
22699
22700 // set boss flag when boss is gone
22701
6/6
✓ Branch 0 taken 6341859 times.
✓ Branch 1 taken 67385 times.
✓ Branch 2 taken 113421 times.
✓ Branch 3 taken 6228438 times.
✓ Branch 4 taken 85999 times.
✓ Branch 5 taken 27422 times.
6409244 if(loaded_enemies && tmpscr->enemyflags&efBOSS && !hasmainguy)
22702 {
22703 27422 game->lvlitems[dlevel]|=liBOSS;
22704 27422 stop_sfx(tmpscr->bosssfx);
22705 27422 }
22706
22707
2/2
✓ Branch 0 taken 6394945 times.
✓ Branch 1 taken 14299 times.
6409244 if(getmapflag(mCHEST)) // if special stuff done before
22708 {
22709 14299 remove_chests((currscr>=128)?1:0);
22710 14299 }
22711
22712
1/2
✓ Branch 0 taken 6409244 times.
✗ Branch 1 not taken.
6409244 if(getmapflag(mLOCKEDCHEST)) // if special stuff done before
22713 {
22714 remove_lockedchests((currscr>=128)?1:0);
22715 }
22716
22717
1/2
✓ Branch 0 taken 6409244 times.
✗ Branch 1 not taken.
6409244 if(getmapflag(mBOSSCHEST)) // if special stuff done before
22718 {
22719 remove_bosschests((currscr>=128)?1:0);
22720 }
22721
22722 6409244 clear_xstatecombos((currscr>=128)?1:0);
22723
22724
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6409244 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6409244 if((hasitem&8) && triggered_screen_secrets)
22725 {
22726 int32_t Item=tmpscr->item;
22727
22728 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
22729 {
22730 items.add(new item((zfix)tmpscr->itemx,
22731 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
22732 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
22733 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
22734 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
22735 }
22736
22737 hasitem &= ~8;
22738 }
22739 6409244 }
22740
22741 //Gets the 4 comboposes indicated by the coordinates, replacing duplicates with '-1'
22742 4400726 void getPoses(int32_t* poses, int32_t x1, int32_t y1, int32_t x2, int32_t y2)
22743 {
22744 int32_t tmp;
22745 4400726 poses[0] = COMBOPOS(x1,y1);
22746
22747 4400726 tmp = COMBOPOS(x1,y2);
22748
2/2
✓ Branch 0 taken 3482484 times.
✓ Branch 1 taken 918242 times.
4400726 if(tmp == poses[0])
22749 3482484 poses[1] = -1;
22750 918242 else poses[1] = tmp;
22751
22752 4400726 tmp = COMBOPOS(x2,y1);
22753
3/4
✓ Branch 0 taken 1923419 times.
✓ Branch 1 taken 2477307 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1923419 times.
4400726 if(tmp == poses[0] || tmp == poses[1])
22754 2477307 poses[2] = -1;
22755 1923419 else poses[2] = tmp;
22756
22757 4400726 tmp = COMBOPOS(x2,y2);
22758
6/6
✓ Branch 0 taken 2466160 times.
✓ Branch 1 taken 1934566 times.
✓ Branch 2 taken 1923419 times.
✓ Branch 3 taken 542741 times.
✓ Branch 4 taken 1547918 times.
✓ Branch 5 taken 375501 times.
4400726 if(tmp == poses[0] || tmp == poses[1] || tmp == poses[2])
22759 4025225 poses[3] = -1;
22760 375501 else poses[3] = tmp;
22761 4400726 }
22762
22763 6404678 void HeroClass::checkspecial2(int32_t *ls)
22764 {
22765
6/8
✓ Branch 0 taken 5744343 times.
✓ Branch 1 taken 660335 times.
✓ Branch 2 taken 5693066 times.
✓ Branch 3 taken 51277 times.
✓ Branch 4 taken 5693066 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5693066 times.
6404678 if(get_bit(quest_rules,qr_OLDSTYLEWARP) && !(diagonalMovement||NO_GRIDLOCK))
22766 {
22767 // Must run fairycircle stuff if currently active, otherwise hero gets stuck!
22768
2/2
✓ Branch 0 taken 15761 times.
✓ Branch 1 taken 5677305 times.
5693066 if (!fairyclk)
22769 {
22770
2/2
✓ Branch 0 taken 1646092 times.
✓ Branch 1 taken 4031213 times.
5677305 if(y.getInt()&7)
22771 1646092 return;
22772
22773
2/2
✓ Branch 0 taken 2204804 times.
✓ Branch 1 taken 1826409 times.
4031213 if(x.getInt()&7)
22774 2204804 return;
22775 1826409 }
22776 1842170 }
22777
22778
2/2
✓ Branch 0 taken 4512 times.
✓ Branch 1 taken 2549270 times.
2553782 if(toogam) return;
22779
22780 2549270 bool didstrig = false;
22781
22782
2/2
✓ Branch 0 taken 5098205 times.
✓ Branch 1 taken 2549267 times.
7647472 for(int32_t i=bigHitbox?0:8; i<16; i+=bigHitbox?15:7)
22783 {
22784
4/4
✓ Branch 0 taken 10196410 times.
✓ Branch 1 taken 5098202 times.
✓ Branch 2 taken 20392817 times.
✓ Branch 3 taken 10196407 times.
35687426 for(int32_t j=0; j<16; j+=15) for(int32_t k=0; k<2; k++)
22785 {
22786
2/2
✓ Branch 0 taken 10196407 times.
✓ Branch 1 taken 10196410 times.
20392817 newcombo const& cmb = combobuf[k>0 ? MAPFFCOMBO(x+j,y+i) : MAPCOMBO(x+j,y+i)];
22787 20392817 int32_t stype = cmb.type;
22788 20392817 int32_t warpsound = cmb.attribytes[0];
22789
2/2
✓ Branch 0 taken 20392615 times.
✓ Branch 1 taken 202 times.
20392817 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
22790 202 stype = cNONE;
22791
2/2
✓ Branch 0 taken 20392814 times.
✓ Branch 1 taken 3 times.
20392817 if(stype==cSWARPA)
22792 {
22793
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(tmpscr->flags5&fDIRECTSWARP)
22794 {
22795 didpit=true;
22796 pitx=x;
22797 pity=y;
22798 }
22799
22800 3 sdir=dir;
22801 3 dowarp(0,0,warpsound);
22802 3 return;
22803 }
22804
22805
1/2
✓ Branch 0 taken 20392814 times.
✗ Branch 1 not taken.
20392814 if(stype==cSWARPB)
22806 {
22807 if(tmpscr->flags5&fDIRECTSWARP)
22808 {
22809 didpit=true;
22810 pitx=x;
22811 pity=y;
22812 }
22813
22814 sdir=dir;
22815 dowarp(0,1,warpsound);
22816 return;
22817 }
22818
22819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20392814 times.
20392814 if(stype==cSWARPC)
22820 {
22821 if(tmpscr->flags5&fDIRECTSWARP)
22822 {
22823 didpit=true;
22824 pitx=x;
22825 pity=y;
22826 }
22827
22828 sdir=dir;
22829 dowarp(0,2,warpsound);
22830 return;
22831 }
22832
22833
1/2
✓ Branch 0 taken 20392814 times.
✗ Branch 1 not taken.
20392814 if(stype==cSWARPD)
22834 {
22835 if(tmpscr->flags5&fDIRECTSWARP)
22836 {
22837 didpit=true;
22838 pitx=x;
22839 pity=y;
22840 }
22841
22842 sdir=dir;
22843 dowarp(0,3,warpsound);
22844 return;
22845 }
22846
22847
1/2
✓ Branch 0 taken 20392814 times.
✗ Branch 1 not taken.
20392814 if(stype==cSWARPR)
22848 {
22849 if(tmpscr->flags5&fDIRECTSWARP)
22850 {
22851 didpit=true;
22852 pitx=x;
22853 pity=y;
22854 }
22855
22856 sdir=dir;
22857 dowarp(0,(zc_oldrand()%4),warpsound);
22858 return;
22859 }
22860
22861 20392814 int32_t pos = COMBOPOS(x+j, y+i);
22862
4/4
✓ Branch 0 taken 20390658 times.
✓ Branch 1 taken 2156 times.
✓ Branch 2 taken 20392104 times.
✓ Branch 3 taken 710 times.
20392814 if((stype==cSTRIGNOFLAG || stype==cSTRIGFLAG) && stepsecret!=pos)
22863 {
22864 // zprint("Step Secs\n");
22865
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
710 if(stype==cSTRIGFLAG && canPermSecret())
22866 {
22867 if(!didstrig)
22868 {
22869 stepsecret = pos;
22870
22871 if(!(tmpscr->flags5&fTEMPSECRETS))
22872 {
22873 setmapflag(mSECRET);
22874 }
22875 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
22876 //zprint("Step Secrets SFX: %d\n", thesfx);
22877 sfx(warpsound,pan((int32_t)x));
22878 hidden_entrance(0,true,false);
22879 didstrig = true;
22880 }
22881 }
22882 else
22883 {
22884
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 345 times.
710 if(!didstrig)
22885 {
22886 345 stepsecret = pos;
22887 345 bool only16_31 = get_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
22888 345 hidden_entrance(0,true,only16_31);
22889 345 didstrig = true;
22890 //play trigger sound
22891 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
22892 //zprint("Step Secrets SFX: %d\n", thesfx);
22893 //sfx(thesfx,pan((int32_t)x));
22894 345 sfx(warpsound,pan((int32_t)x));
22895 345 }
22896 }
22897 710 }
22898 30589221 }
22899 5098202 }
22900
22901 2549267 bool RaftPass = false;//Special case for the raft, where only the raft stuff gets checked and nothing else.
22902
22903 // check if he's standing on a warp he just came out of
22904 // But if the QR is checked, it uses the old logic, cause some quests like Ballad of a Bloodline warp you onto a trigger and this new logic bricks that.
22905
2/2
✓ Branch 0 taken 920014 times.
✓ Branch 1 taken 1629253 times.
2549267 if (!get_bit(quest_rules,qr_210_WARPRETURN))
22906 {
22907
6/6
✓ Branch 0 taken 1627926 times.
✓ Branch 1 taken 1327 times.
✓ Branch 2 taken 191923 times.
✓ Branch 3 taken 1436003 times.
✓ Branch 4 taken 15329 times.
✓ Branch 5 taken 176594 times.
1629253 if(((int32_t)y>=warpy-8&&(int32_t)y<=warpy+7)&&warpy!=-1)
22908 {
22909
5/6
✓ Branch 0 taken 175973 times.
✓ Branch 1 taken 621 times.
✓ Branch 2 taken 174984 times.
✓ Branch 3 taken 989 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 174984 times.
176594 if(((int32_t)x>=warpx-8&&(int32_t)x<=warpx+7)&&warpx!=-1)
22910 {
22911
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 174979 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
174984 if (get_bit(quest_rules, qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
22912 174984 else return;
22913 }
22914 1610 }
22915 1454269 }
22916 else
22917 {
22918
2/2
✓ Branch 0 taken 761390 times.
✓ Branch 1 taken 158624 times.
920014 if((int(y)&0xF8)==warpy)
22919 {
22920
2/2
✓ Branch 0 taken 1380 times.
✓ Branch 1 taken 157244 times.
158624 if(x==warpx)
22921 {
22922
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 157244 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
157244 if (get_bit(quest_rules, qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
22923 157244 else return;
22924 }
22925 1380 }
22926 }
22927
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 2216873 times.
2217039 if (!RaftPass) warpy=-1;
22928
22929
6/6
✓ Branch 0 taken 2213502 times.
✓ Branch 1 taken 3205 times.
✓ Branch 2 taken 148327 times.
✓ Branch 3 taken 2065175 times.
✓ Branch 4 taken 110700 times.
✓ Branch 5 taken 37627 times.
2217039 if(((int32_t)y<raftwarpy-(get_bit(quest_rules, qr_BETTER_RAFT_2)?12:8)||(int32_t)y>raftwarpy+(get_bit(quest_rules, qr_BETTER_RAFT_2)?3:7))||raftwarpy==-1)
22930 {
22931 2106007 raftwarpy = -1;
22932 2106007 }
22933
6/6
✓ Branch 0 taken 2214233 times.
✓ Branch 1 taken 2474 times.
✓ Branch 2 taken 130039 times.
✓ Branch 3 taken 2084194 times.
✓ Branch 4 taken 94761 times.
✓ Branch 5 taken 35278 times.
2216707 if (((int32_t)x<raftwarpx - 8 || (int32_t)x>raftwarpx + 7) || raftwarpx == -1)
22934 {
22935 2121946 raftwarpx = -1;
22936 2121946 }
22937 2216707 int32_t tx=x;
22938 2216707 int32_t ty=y;
22939
22940 2216707 int32_t flag=0;
22941 2216707 int32_t flag2=0;
22942 2216707 int32_t flag3=0;
22943 2216707 int32_t type=0;
22944 2216707 int32_t water=0;
22945 2216707 int32_t index = 0;
22946
22947 2216707 bool setsave=false;
22948 2216707 int32_t warpsfx2 = 0;
22949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2216707 times.
2216707 if (RaftPass) goto RaftingStuff;
22950
22951 //bool gotpit=false;
22952
22953 int32_t x1,x2,y1,y2;
22954 2216707 x1 = tx;
22955 2216707 x2 = tx+15;
22956 2216707 y1 = ty;
22957 2216707 y2 = ty+15;
22958
22959
5/6
✓ Branch 0 taken 1554959 times.
✓ Branch 1 taken 661748 times.
✓ Branch 2 taken 1554959 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 166 times.
✓ Branch 5 taken 1555125 times.
2216707 if((diagonalMovement||NO_GRIDLOCK))
22960 {
22961 661914 x1 = tx+4;
22962 661914 x2 = tx+11;
22963 661914 y1 = ty+4;
22964 661914 y2 = ty+11;
22965 661914 }
22966
22967 int32_t types[4];
22968 2217039 types[0]=types[1]=types[2]=types[3]=-1;
22969 int32_t cids[4];
22970 int32_t ffcids[4];
22971 2217039 cids[0]=cids[1]=cids[2]=cids[3]=-1;
22972 2217039 ffcids[0]=ffcids[1]=ffcids[2]=ffcids[3]=-1;
22973 //
22974 // First, let's find flag1 (combo flag), flag2 (inherent flag) and flag3 (FFC flag)...
22975 //
22976 2217039 types[0] = MAPFLAG(x1,y1);
22977 2217039 types[1] = MAPFLAG(x1,y2);
22978 2217039 types[2] = MAPFLAG(x2,y1);
22979 2217039 types[3] = MAPFLAG(x2,y2);
22980
22981
22982 //MAPFFCOMBO
22983
22984
22985
6/6
✓ Branch 0 taken 2168794 times.
✓ Branch 1 taken 48245 times.
✓ Branch 2 taken 2163094 times.
✓ Branch 3 taken 5700 times.
✓ Branch 4 taken 24748 times.
✓ Branch 5 taken 2138346 times.
2217039 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
22986 2138346 flag = types[0];
22987
22988 // 2.10 compatibility...
22989
8/10
✓ Branch 0 taken 48458 times.
✓ Branch 1 taken 30235 times.
✓ Branch 2 taken 40925 times.
✓ Branch 3 taken 7533 times.
✓ Branch 4 taken 29907 times.
✓ Branch 5 taken 11018 times.
✓ Branch 6 taken 29907 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 29907 times.
78693 else if(y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
22990 11018 flag = types[0];
22991
22992
22993 2217039 types[0] = MAPCOMBOFLAG(x1,y1);
22994 2217039 types[1] = MAPCOMBOFLAG(x1,y2);
22995 2217039 types[2] = MAPCOMBOFLAG(x2,y1);
22996 2217039 types[3] = MAPCOMBOFLAG(x2,y2);
22997
22998
6/6
✓ Branch 0 taken 2214943 times.
✓ Branch 1 taken 2096 times.
✓ Branch 2 taken 2214554 times.
✓ Branch 3 taken 389 times.
✓ Branch 4 taken 680 times.
✓ Branch 5 taken 2213874 times.
2217039 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
22999 2213874 flag2 = types[0];
23000
23001 2217039 types[0] = MAPFFCOMBOFLAG(x1,y1);
23002 2217039 types[1] = MAPFFCOMBOFLAG(x1,y2);
23003 2217039 types[2] = MAPFFCOMBOFLAG(x2,y1);
23004 2217039 types[3] = MAPFFCOMBOFLAG(x2,y2);
23005
23006
23007 //
23008
23009
6/6
✓ Branch 0 taken 2216855 times.
✓ Branch 1 taken 184 times.
✓ Branch 2 taken 2216848 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 2216844 times.
2217039 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
23010 2216844 flag3 = types[0];
23011
23012 //
23013 // Now, let's check for warp combos...
23014 //
23015
23016 //
23017
23018 2217039 cids[0] = MAPCOMBO(x1,y1);
23019 2217039 cids[1] = MAPCOMBO(x1,y2);
23020 2217039 cids[2] = MAPCOMBO(x2,y1);
23021 2217039 cids[3] = MAPCOMBO(x2,y2);
23022
23023 2217039 types[0] = COMBOTYPE(x1,y1);
23024
23025
2/2
✓ Branch 0 taken 2193922 times.
✓ Branch 1 taken 23117 times.
2217039 if(MAPFFCOMBO(x1,y1))
23026 {
23027 23117 types[0] = FFCOMBOTYPE(x1,y1);
23028 23117 cids[0] = MAPFFCOMBO(x1,y1);
23029 23117 }
23030
23031 2217039 types[1] = COMBOTYPE(x1,y2);
23032
23033
2/2
✓ Branch 0 taken 2199085 times.
✓ Branch 1 taken 17954 times.
2217039 if(MAPFFCOMBO(x1,y2))
23034 {
23035 17954 types[1] = FFCOMBOTYPE(x1,y2);
23036 17954 cids[1] = MAPFFCOMBO(x1,y2);
23037 17954 }
23038
23039 2217039 types[2] = COMBOTYPE(x2,y1);
23040
23041
2/2
✓ Branch 0 taken 2193711 times.
✓ Branch 1 taken 23328 times.
2217039 if(MAPFFCOMBO(x2,y1))
23042 {
23043 23328 types[2] = FFCOMBOTYPE(x2,y1);
23044 23328 cids[2] = MAPFFCOMBO(x2,y1);
23045 23328 }
23046 2217039 types[3] = COMBOTYPE(x2,y2);
23047
23048
2/2
✓ Branch 0 taken 2198569 times.
✓ Branch 1 taken 18470 times.
2217039 if(MAPFFCOMBO(x2,y2))
23049 {
23050 18470 types[3] = FFCOMBOTYPE(x2,y2);
23051 18470 cids[3] = MAPFFCOMBO(x2,y2);
23052 18470 }
23053 // Change B, C and D warps into A, for the comparison below...
23054
2/2
✓ Branch 0 taken 8867492 times.
✓ Branch 1 taken 2217039 times.
11084531 for(int32_t i=0; i<4; i++)
23055 {
23056
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 8867168 times.
8867492 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
23057 {
23058 324 types[i] = cNONE;
23059 324 continue;
23060 }
23061
2/2
✓ Branch 0 taken 2456 times.
✓ Branch 1 taken 8864712 times.
8867168 if(types[i]==cCAVE)
23062 {
23063 2456 index=0;
23064 2456 warpsfx2 = combobuf[cids[i]].attribytes[0];
23065 2456 }
23066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8864712 times.
8864712 else if(types[i]==cCAVEB)
23067 {
23068 types[i]=cCAVE;
23069 index=1;
23070 warpsfx2 = combobuf[cids[i]].attribytes[0];
23071 }
23072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8864712 times.
8864712 else if(types[i]==cCAVEC)
23073 {
23074 types[i]=cCAVE;
23075 index=2;
23076 warpsfx2 = combobuf[cids[i]].attribytes[0];
23077 }
23078
1/2
✓ Branch 0 taken 8864712 times.
✗ Branch 1 not taken.
8864712 else if(types[i]==cCAVED)
23079 {
23080 types[i]=cCAVE;
23081 index=3;
23082 warpsfx2 = combobuf[cids[i]].attribytes[0];
23083 }
23084
23085
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 8866660 times.
8867168 if(types[i]==cPIT)
23086 {
23087 508 index=0;
23088 508 warpsfx2 = combobuf[cids[i]].attribytes[0];
23089 508 }
23090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8866660 times.
8866660 else if(types[i]==cPITB)
23091 {
23092 types[i]=cPIT;
23093 warpsfx2 = combobuf[cids[i]].attribytes[0];
23094 index=1;
23095 }
23096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8866660 times.
8866660 else if(types[i]==cPITC)
23097 {
23098 types[i]=cPIT;
23099 warpsfx2 = combobuf[cids[i]].attribytes[0];
23100 index=2;
23101 }
23102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8866660 times.
8866660 else if(types[i]==cPITD)
23103 {
23104 types[i]=cPIT;
23105 warpsfx2 = combobuf[cids[i]].attribytes[0];
23106 index=3;
23107 }
23108
1/2
✓ Branch 0 taken 8866660 times.
✗ Branch 1 not taken.
8866660 else if(types[i]==cPITR)
23109 {
23110 types[i]=cPIT;
23111 warpsfx2 = combobuf[cids[i]].attribytes[0];
23112 index=zc_oldrand()%4;
23113 }
23114
23115
2/2
✓ Branch 0 taken 10748 times.
✓ Branch 1 taken 8856420 times.
8867168 if(types[i]==cSTAIR)
23116 {
23117 10748 index=0;
23118 10748 warpsfx2 = combobuf[cids[i]].attribytes[0];
23119 10748 }
23120
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 8856320 times.
8856420 else if(types[i]==cSTAIRB)
23121 {
23122 100 types[i]=cSTAIR;
23123 100 warpsfx2 = combobuf[cids[i]].attribytes[0];
23124 100 index=1;
23125 100 }
23126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8856320 times.
8856320 else if(types[i]==cSTAIRC)
23127 {
23128 types[i]=cSTAIR;
23129 warpsfx2 = combobuf[cids[i]].attribytes[0];
23130 index=2;
23131 }
23132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8856320 times.
8856320 else if(types[i]==cSTAIRD)
23133 {
23134 types[i]=cSTAIR;
23135 warpsfx2 = combobuf[cids[i]].attribytes[0];
23136 index=3;
23137 }
23138
1/2
✓ Branch 0 taken 8856320 times.
✗ Branch 1 not taken.
8856320 else if(types[i]==cSTAIRR)
23139 {
23140 types[i]=cSTAIR;
23141 index=zc_oldrand()%4;
23142 warpsfx2 = combobuf[cids[i]].attribytes[0];
23143 }
23144
23145
2/2
✓ Branch 0 taken 1279 times.
✓ Branch 1 taken 8865889 times.
8867168 if(types[i]==cCAVE2)
23146 {
23147 1279 index=0;
23148 1279 warpsfx2 = combobuf[cids[i]].attribytes[0];
23149 1279 }
23150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8865889 times.
8865889 else if(types[i]==cCAVE2B)
23151 {
23152 types[i]=cCAVE2;
23153 index=1;
23154 warpsfx2 = combobuf[cids[i]].attribytes[0];
23155 }
23156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8865889 times.
8865889 else if(types[i]==cCAVE2C)
23157 {
23158 types[i]=cCAVE2;
23159 warpsfx2 = combobuf[cids[i]].attribytes[0];
23160 index=2;
23161 }
23162
1/2
✓ Branch 0 taken 8865889 times.
✗ Branch 1 not taken.
8865889 else if(types[i]==cCAVE2D)
23163 {
23164 types[i]=cCAVE2;
23165 warpsfx2 = combobuf[cids[i]].attribytes[0];
23166 index=3;
23167 }
23168
23169
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 8867092 times.
8867168 if(types[i]==cSWIMWARP)
23170 {
23171 76 index=0;
23172 76 warpsfx2 = combobuf[cids[i]].attribytes[0];
23173 76 }
23174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8867092 times.
8867092 else if(types[i]==cSWIMWARPB)
23175 {
23176 types[i]=cSWIMWARP;
23177 warpsfx2 = combobuf[cids[i]].attribytes[0];
23178 index=1;
23179 }
23180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8867092 times.
8867092 else if(types[i]==cSWIMWARPC)
23181 {
23182 types[i]=cSWIMWARP;
23183 warpsfx2 = combobuf[cids[i]].attribytes[0];
23184 index=2;
23185 }
23186
1/2
✓ Branch 0 taken 8867092 times.
✗ Branch 1 not taken.
8867092 else if(types[i]==cSWIMWARPD)
23187 {
23188 types[i]=cSWIMWARP;
23189 warpsfx2 = combobuf[cids[i]].attribytes[0];
23190 index=3;
23191 }
23192
23193
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 8866660 times.
8867168 if(types[i]==cDIVEWARP)
23194 {
23195 508 index=0;
23196 508 warpsfx2 = combobuf[cids[i]].attribytes[0];
23197 508 }
23198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8866660 times.
8866660 else if(types[i]==cDIVEWARPB)
23199 {
23200 types[i]=cDIVEWARP;
23201 warpsfx2 = combobuf[cids[i]].attribytes[0];
23202 index=1;
23203 }
23204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8866660 times.
8866660 else if(types[i]==cDIVEWARPC)
23205 {
23206 types[i]=cDIVEWARP;
23207 warpsfx2 = combobuf[cids[i]].attribytes[0];
23208 index=2;
23209 }
23210
1/2
✓ Branch 0 taken 8866660 times.
✗ Branch 1 not taken.
8866660 else if(types[i]==cDIVEWARPD)
23211 {
23212 types[i]=cDIVEWARP;
23213 warpsfx2 = combobuf[cids[i]].attribytes[0];
23214 index=3;
23215 }
23216
23217
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 8866478 times.
8867168 if(types[i]==cSTEP) warpsfx2 = combobuf[cids[i]].attribytes[0];
23218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8866478 times.
8866478 else if(types[i]==cSTEPSAME) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0];}
23219
2/2
✓ Branch 0 taken 8866462 times.
✓ Branch 1 taken 16 times.
8866478 else if(types[i]==cSTEPALL) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0]; }
23220 8867168 }
23221
23222 // Special case for step combos; otherwise, they act oddly in some cases
23223
8/8
✓ Branch 0 taken 2066473 times.
✓ Branch 1 taken 150566 times.
✓ Branch 2 taken 2047884 times.
✓ Branch 3 taken 18589 times.
✓ Branch 4 taken 83 times.
✓ Branch 5 taken 169072 times.
✓ Branch 6 taken 22411 times.
✓ Branch 7 taken 22328 times.
2217039 if((types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])||(types[1]==cSTEP&&types[3]==cSTEP))
23224 {
23225
7/8
✓ Branch 0 taken 2010758 times.
✓ Branch 1 taken 14715 times.
✓ Branch 2 taken 2010758 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 628 times.
✓ Branch 5 taken 2010130 times.
✓ Branch 6 taken 130 times.
✓ Branch 7 taken 498 times.
2070295 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
23226 2010628 type = types[1];
23227 2025473 }
23228
23229 //Generic Step
23230
7/8
✓ Branch 0 taken 2200495 times.
✓ Branch 1 taken 16378 times.
✓ Branch 2 taken 2200495 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 630 times.
✓ Branch 5 taken 2199865 times.
✓ Branch 6 taken 132 times.
✓ Branch 7 taken 498 times.
2216873 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
23231 {
23232 int32_t poses[4];
23233 int32_t sensPoses[4];
23234 2200363 int32_t xPoses[4] = {tx + 4, tx + 11, tx, tx + 15};
23235 2200363 int32_t yPoses[4] = {ty + 4, ty + 11, ty+(bigHitbox?0:8), ty + 15};
23236
4/6
✓ Branch 0 taken 1539181 times.
✓ Branch 1 taken 661182 times.
✓ Branch 2 taken 1539181 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1539181 times.
2200363 if(diagonalMovement||NO_GRIDLOCK)
23237 661182 getPoses(poses, tx+4, ty+4, tx+11, ty+11);
23238 1539181 else getPoses(poses, tx, ty, tx+15, ty+15);
23239 2200363 getPoses(sensPoses, tx, ty+(bigHitbox?0:8), tx+15, ty+15);
23240 2200363 bool hasStep[4] = {false};
23241
2/2
✓ Branch 0 taken 8801452 times.
✓ Branch 1 taken 2200363 times.
11001815 for(auto p = 0; p < 4; ++p)
23242 {
23243
2/2
✓ Branch 0 taken 8800587 times.
✓ Branch 1 taken 61604974 times.
70405561 for(auto lyr = 0; lyr < 7; ++lyr)
23244 {
23245
2/2
✓ Branch 0 taken 28664804 times.
✓ Branch 1 taken 32940170 times.
61604974 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
23246
4/4
✓ Branch 0 taken 28664804 times.
✓ Branch 1 taken 32940170 times.
✓ Branch 2 taken 865 times.
✓ Branch 3 taken 61604109 times.
61604974 if((cmb && (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS)))
23247 61604974 || types[p] == cSTEP)
23248 {
23249 865 hasStep[p] = true;
23250 865 break;
23251 }
23252 61604109 }
23253 8801452 }
23254 2200363 bool canNormalStep = true;
23255
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 2200769 times.
2200868 for(auto p = 0; p < 4; ++p)
23256 {
23257
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 2200516 times.
2200769 if(poses[p] < 0) continue;
23258
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 2200264 times.
2200516 if(!hasStep[p])
23259 {
23260 2200264 canNormalStep = false;
23261 2200264 break;
23262 }
23263 252 }
23264
2/2
✓ Branch 0 taken 8801452 times.
✓ Branch 1 taken 2200363 times.
11001815 for(auto p = 0; p < 4; ++p)
23265 {
23266
2/2
✓ Branch 0 taken 61610164 times.
✓ Branch 1 taken 8801452 times.
70411616 for(auto lyr = 0; lyr < 7; ++lyr)
23267 {
23268
2/2
✓ Branch 0 taken 28668080 times.
✓ Branch 1 taken 32942084 times.
61610164 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
23269
2/2
✓ Branch 0 taken 24657136 times.
✓ Branch 1 taken 36953028 times.
61610164 newcombo const* cmb2 = sensPoses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[sensPoses[p]]];
23270
6/6
✓ Branch 0 taken 2772 times.
✓ Branch 1 taken 61607392 times.
✓ Branch 2 taken 1162 times.
✓ Branch 3 taken 1610 times.
✓ Branch 4 taken 1148 times.
✓ Branch 5 taken 14 times.
61610164 if(canNormalStep && cmb && (cmb->triggerflags[0] & combotriggerSTEP))
23271 {
23272 14 do_trigger_combo(lyr,poses[p]);
23273
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 9 times.
14 if(poses[p] == sensPoses[p]) continue;
23274 9 }
23275
4/4
✓ Branch 0 taken 24657131 times.
✓ Branch 1 taken 36953028 times.
✓ Branch 2 taken 24657066 times.
✓ Branch 3 taken 65 times.
61610159 if(cmb2 && (cmb2->triggerflags[0] & combotriggerSTEPSENS))
23276 {
23277 65 do_trigger_combo(lyr,sensPoses[p]);
23278 65 }
23279 61610159 }
23280 8801452 }
23281 2200363 word c = tmpscr->numFFC();
23282
2/2
✓ Branch 0 taken 66432743 times.
✓ Branch 1 taken 2200363 times.
68633106 for(word i=0; i<c; i++)
23283 {
23284 66432743 bool found = false;
23285
2/2
✓ Branch 0 taken 132865486 times.
✓ Branch 1 taken 66432743 times.
199298229 for(auto xch = 0; xch < 2; ++xch)
23286 {
23287
2/2
✓ Branch 0 taken 265730972 times.
✓ Branch 1 taken 132865486 times.
398596458 for(auto ych = 0; ych < 2; ++ych)
23288 {
23289
2/2
✓ Branch 0 taken 265645077 times.
✓ Branch 1 taken 85895 times.
265730972 if (ffcIsAt(i, xPoses[xch], yPoses[ych]))
23290 {
23291 85895 found = true;
23292 85895 }
23293 265730972 }
23294 132865486 }
23295
2/2
✓ Branch 0 taken 66398798 times.
✓ Branch 1 taken 33945 times.
66432743 if (found)
23296 {
23297 33945 ffcdata& ffc = tmpscr->ffcs[i];
23298 33945 newcombo const* cmb = &combobuf[ffc.getData()];
23299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33945 times.
33945 if (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS))
23300 {
23301 do_trigger_combo_ffc(i);
23302 }
23303 33945 }
23304 66432743 }
23305 2200363 }
23306
23307 //
23308 // Now, let's check for Save combos...
23309 //
23310 2216873 x1 = tx+4;
23311 2216873 x2 = tx+11;
23312 2216873 y1 = ty+4;
23313 2216873 y2 = ty+11;
23314
23315 2216873 types[0] = COMBOTYPE(x1,y1);
23316 2216873 cids[0] = MAPCOMBO(x1,y1);
23317
23318
2/2
✓ Branch 0 taken 2193779 times.
✓ Branch 1 taken 23094 times.
2216873 if(MAPFFCOMBO(x1,y1))
23319 {
23320 23094 types[0] = FFCOMBOTYPE(x1,y1);
23321 23094 cids[0] = MAPFFCOMBO(x1,y1);
23322 23094 }
23323
23324 2216873 types[1] = COMBOTYPE(x1,y2);
23325 2216873 cids[1] = MAPCOMBO(x1,y2);
23326
23327
2/2
✓ Branch 0 taken 2198905 times.
✓ Branch 1 taken 17968 times.
2216873 if(MAPFFCOMBO(x1,y2))
23328 {
23329 17968 types[1] = FFCOMBOTYPE(x1,y2);
23330 17968 cids[1] = MAPFFCOMBO(x1,y2);
23331 17968 }
23332
23333 2216873 types[2] = COMBOTYPE(x2,y1);
23334 2216873 cids[2] = MAPCOMBO(x2,y1);
23335
23336
2/2
✓ Branch 0 taken 2193560 times.
✓ Branch 1 taken 23313 times.
2216873 if(MAPFFCOMBO(x2,y1))
23337 {
23338 23313 types[2] = FFCOMBOTYPE(x2,y1);
23339 23313 cids[2] = MAPFFCOMBO(x2,y1);
23340 23313 }
23341
23342 2216873 types[3] = COMBOTYPE(x2,y2);
23343 2216873 cids[3] = MAPCOMBO(x2,y2);
23344
23345
2/2
✓ Branch 0 taken 2198388 times.
✓ Branch 1 taken 18485 times.
2216873 if(MAPFFCOMBO(x2,y2))
23346 {
23347 18485 types[3] = FFCOMBOTYPE(x2,y2);
23348 18485 cids[3] = MAPFFCOMBO(x2,y2);
23349 18485 }
23350
23351
23352
2/2
✓ Branch 0 taken 2216873 times.
✓ Branch 1 taken 8867492 times.
11084365 for(int32_t i=0; i<4; i++)
23353 {
23354
2/2
✓ Branch 0 taken 8867168 times.
✓ Branch 1 taken 324 times.
8867492 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
23355 {
23356
2/4
✓ Branch 0 taken 324 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 324 times.
✗ Branch 3 not taken.
324 if(types[i] == cSAVE || types[i] == cSAVE2)
23357 {
23358 types[i] = cNONE;
23359 setsave = false;
23360 break;
23361 }
23362 324 }
23363
2/2
✓ Branch 0 taken 8866206 times.
✓ Branch 1 taken 1286 times.
8867492 if(types[i]==cSAVE) setsave=true;
23364
23365
1/2
✓ Branch 0 taken 8867492 times.
✗ Branch 1 not taken.
8867492 if(types[i]==cSAVE2) setsave=true;
23366 8867492 }
23367
23368
8/8
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 2216442 times.
✓ Branch 2 taken 343 times.
✓ Branch 3 taken 88 times.
✓ Branch 4 taken 335 times.
✓ Branch 5 taken 8 times.
✓ Branch 6 taken 106 times.
✓ Branch 7 taken 229 times.
2216873 if(setsave && types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
23369 {
23370 229 last_savepoint_id = cids[0];
23371 229 type = types[0];
23372 229 }
23373 //
23374 // Now, let's check for Drowning combos...
23375 //
23376
3/4
✓ Branch 0 taken 1455857 times.
✓ Branch 1 taken 761016 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1455857 times.
2216873 if(get_bit(quest_rules,qr_DROWN) || CanSideSwim())
23377 {
23378 761016 y1 = ty+9;
23379 761016 y2 = ty+15;
23380
2/2
✓ Branch 0 taken 231501 times.
✓ Branch 1 taken 529515 times.
761016 if (get_bit(quest_rules, qr_SMARTER_WATER))
23381 {
23382
4/4
✓ Branch 0 taken 1898 times.
✓ Branch 1 taken 229603 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1597 times.
233101 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
23383
2/2
✓ Branch 0 taken 1742 times.
✓ Branch 1 taken 156 times.
1898 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
23384
2/2
✓ Branch 0 taken 1600 times.
✓ Branch 1 taken 142 times.
1742 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
23385 1600 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
23386 231501 }
23387 else
23388 {
23389 529515 types[0] = COMBOTYPE(x1,y1);
23390
23391
2/2
✓ Branch 0 taken 11301 times.
✓ Branch 1 taken 518214 times.
529515 if(MAPFFCOMBO(x1,y1))
23392 11301 types[0] = FFCOMBOTYPE(x1,y1);
23393
23394 529515 types[1] = COMBOTYPE(x1,y2);
23395
23396
2/2
✓ Branch 0 taken 10868 times.
✓ Branch 1 taken 518647 times.
529515 if(MAPFFCOMBO(x1,y2))
23397 10868 types[1] = FFCOMBOTYPE(x1,y2);
23398
23399 529515 types[2] = COMBOTYPE(x2,y1);
23400
23401
2/2
✓ Branch 0 taken 12015 times.
✓ Branch 1 taken 517500 times.
529515 if(MAPFFCOMBO(x2,y1))
23402 12015 types[2] = FFCOMBOTYPE(x2,y1);
23403
23404 529515 types[3] = COMBOTYPE(x2,y2);
23405
23406
2/2
✓ Branch 0 taken 11358 times.
✓ Branch 1 taken 518157 times.
529515 if(MAPFFCOMBO(x2,y2))
23407 11358 types[3] = FFCOMBOTYPE(x2,y2);
23408
23409 529515 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
23410
2/2
✓ Branch 0 taken 11562 times.
✓ Branch 1 taken 517953 times.
529515 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
23411 11562 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
23412
23413
5/6
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 527623 times.
✓ Branch 2 taken 1888 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 1852 times.
✗ Branch 5 not taken.
531367 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
23414
3/4
✓ Branch 0 taken 1852 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 1852 times.
✗ Branch 3 not taken.
1888 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
23415 1852 water = typec;
23416 }
23417 761016 }
23418
23419
23420 // Pits have a bigger 'hitbox' than stairs...
23421 2216873 x1 = tx+7;
23422 2216873 x2 = tx+8;
23423 2216873 y1 = ty+7+(bigHitbox?0:4);
23424 2216873 y2 = ty+8+(bigHitbox?0:4);
23425
23426 2216873 types[0] = COMBOTYPE(x1,y1);
23427 2216873 cids[0] = MAPCOMBO(x1,y1);
23428
23429
2/2
✓ Branch 0 taken 2198351 times.
✓ Branch 1 taken 18522 times.
2216873 if(MAPFFCOMBO(x1,y1))
23430 {
23431 18522 types[0] = FFCOMBOTYPE(x1,y1);
23432 18522 cids[0] = MAPFFCOMBO(x1,y1);
23433 18522 }
23434
23435 2216873 types[1] = COMBOTYPE(x1,y2);
23436 2216873 cids[1] = MAPCOMBO(x1,y2);
23437
23438
2/2
✓ Branch 0 taken 2198202 times.
✓ Branch 1 taken 18671 times.
2216873 if(MAPFFCOMBO(x1,y2))
23439 {
23440 18671 types[1] = FFCOMBOTYPE(x1,y2);
23441 18671 cids[1] = MAPFFCOMBO(x1,y2);
23442 18671 }
23443 2216873 types[2] = COMBOTYPE(x2,y1);
23444 2216873 cids[2] = MAPCOMBO(x2,y1);
23445
23446
2/2
✓ Branch 0 taken 2198619 times.
✓ Branch 1 taken 18254 times.
2216873 if(MAPFFCOMBO(x2,y1))
23447 {
23448 18254 types[2] = FFCOMBOTYPE(x2,y1);
23449 18254 cids[2] = MAPFFCOMBO(x2,y1);
23450 18254 }
23451
23452 2216873 types[3] = COMBOTYPE(x2,y2);
23453 2216873 cids[3] = MAPCOMBO(x2,y2);
23454
23455
2/2
✓ Branch 0 taken 2198464 times.
✓ Branch 1 taken 18409 times.
2216873 if(MAPFFCOMBO(x2,y2))
23456 {
23457 18409 types[3] = FFCOMBOTYPE(x2,y2);
23458 18409 cids[3] = MAPFFCOMBO(x2,y2);
23459 18409 }
23460
23461
2/2
✓ Branch 0 taken 8867492 times.
✓ Branch 1 taken 2216873 times.
11084365 for(int32_t i=0; i<4; i++)
23462 {
23463
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 8867228 times.
8867492 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
23464 {
23465 264 types[i] = cNONE;
23466 264 continue;
23467 }
23468
2/2
✓ Branch 0 taken 380 times.
✓ Branch 1 taken 8866848 times.
8867228 if(types[i]==cPIT)
23469 {
23470 380 index=0;
23471 380 warpsfx2 = combobuf[cids[i]].attribytes[0];
23472 380 }
23473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8866848 times.
8866848 else if(types[i]==cPITB)
23474 {
23475 types[i]=cPIT;
23476 index=1;
23477 warpsfx2 = combobuf[cids[i]].attribytes[0];
23478 }
23479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8866848 times.
8866848 else if(types[i]==cPITC)
23480 {
23481 types[i]=cPIT;
23482 index=2;
23483 warpsfx2 = combobuf[cids[i]].attribytes[0];
23484 }
23485
1/2
✓ Branch 0 taken 8866848 times.
✗ Branch 1 not taken.
8866848 else if(types[i]==cPITD)
23486 {
23487 types[i]=cPIT;
23488 index=3;
23489 warpsfx2 = combobuf[cids[i]].attribytes[0];
23490 }
23491 8867228 }
23492
23493
6/8
✓ Branch 0 taken 2216780 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 2216780 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2216761 times.
✓ Branch 5 taken 19 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2216761 times.
2216873 if(types[0]==cPIT||types[1]==cPIT||types[2]==cPIT||types[3]==cPIT)
23494
3/8
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 112 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
224 if(action!=freeze&&action!=sideswimfreeze&& (!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
23495 112 type=cPIT;
23496
23497 //
23498 // Time to act on our results for type, flag, flag2 and flag3...
23499 //
23500
3/4
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 2216644 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 229 times.
2216873 if(type==cSAVE&&currscr<128)
23501 229 *ls=1;
23502
23503
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2216873 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2216873 if(type==cSAVE2&&currscr<128)
23504 *ls=2;
23505
23506
7/8
✓ Branch 0 taken 2208855 times.
✓ Branch 1 taken 8018 times.
✓ Branch 2 taken 2197783 times.
✓ Branch 3 taken 11072 times.
✓ Branch 4 taken 2197253 times.
✓ Branch 5 taken 530 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2197253 times.
2216873 if(refilling==REFILL_LIFE || flag==mfFAIRY||flag2==mfFAIRY||flag3==mfFAIRY)
23507 {
23508 19620 fairycircle(REFILL_LIFE);
23509
23510
2/2
✓ Branch 0 taken 16361 times.
✓ Branch 1 taken 3259 times.
19620 if(fairyclk!=0) return;
23511 3259 }
23512
23513
4/8
✓ Branch 0 taken 2200512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2200512 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2200512 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2200512 times.
2200512 if(refilling==REFILL_MAGIC || flag==mfMAGICFAIRY||flag2==mfMAGICFAIRY||flag3==mfMAGICFAIRY)
23514 {
23515 fairycircle(REFILL_MAGIC);
23516
23517 if(fairyclk!=0) return;
23518 }
23519
23520
4/8
✓ Branch 0 taken 2200512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2200512 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2200512 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2200512 times.
2200512 if(refilling==REFILL_ALL || flag==mfALLFAIRY||flag2==mfALLFAIRY||flag3==mfALLFAIRY)
23521 {
23522 fairycircle(REFILL_ALL);
23523
23524 if(fairyclk!=0) return;
23525 }
23526
23527 // Just in case Hero was moved off of the fairy flag
23528
1/2
✓ Branch 0 taken 2200512 times.
✗ Branch 1 not taken.
2200512 if(refilling==REFILL_FAIRYDONE)
23529 {
23530 fairycircle(REFILL_NONE);
23531
23532 if(fairyclk!=0) return;
23533 }
23534
23535
5/8
✓ Branch 0 taken 2200504 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2200504 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2200504 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2200504 times.
2200512 if(flag==mfZELDA||flag2==mfZELDA||flag3==mfZELDA || combo_class_buf[type].win_game)
23536 {
23537 8 attackclk = 0; //get rid of Hero's sword if it was stuck out, charged.
23538 8 win_game();
23539 8 return;
23540 }
23541
23542
4/4
✓ Branch 0 taken 2196940 times.
✓ Branch 1 taken 3564 times.
✓ Branch 2 taken 2196940 times.
✓ Branch 3 taken 3564 times.
2200504 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS))
23543 3564 return;
23544
23545
4/4
✓ Branch 0 taken 2196615 times.
✓ Branch 1 taken 325 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 2196606 times.
2196940 if((type==cTRIGNOFLAG || type==cTRIGFLAG))
23546 {
23547
23548
3/4
✓ Branch 0 taken 214 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 214 times.
✗ Branch 3 not taken.
334 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepsecret || get_bit(quest_rules,qr_TRIGGERSREPEAT))
23549 {
23550 334 stepsecret = (((ty+8)&0xF0)+((tx+8)>>4));
23551 334 sfx(combobuf[tmpscr->data[stepsecret]].attribytes[0],pan((int32_t)x));
23552 //zprint("Step Secrets Sound: %d\n", combobuf[tmpscr->data[stepsecret]].attribytes[0]);
23553
23554
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 325 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
334 if(type==cTRIGFLAG && canPermSecret())
23555 {
23556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
23557
23558 9 hidden_entrance(0,true,false);
23559 9 }
23560 else
23561 {
23562 325 bool only16_31 = get_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
23563 325 hidden_entrance(0,true,only16_31);
23564 }
23565 334 }
23566 334 }
23567
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 2196264 times.
2196606 else if(!didstrig)
23568 {
23569 2196264 stepsecret = -1;
23570 2196264 }
23571
23572 //Better? Dock collision
23573
23574 // Drown if:
23575 // * Water (obviously walkable),
23576 // * Quest Rule allows it,
23577 // * Not on stepladder,
23578 // * Not jumping,
23579 // * Not hovering,
23580 // * Not rafting,
23581 // * Not swallowed,
23582 // * Not a dried lake.
23583
23584 // This used to check for swimming too, but I moved that into the block so that you can drown in higher-leveled water. -Dimi
23585
23586
13/22
✓ Branch 0 taken 3393 times.
✓ Branch 1 taken 2193547 times.
✓ Branch 2 taken 3393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3393 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3393 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3393 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 3386 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3010 times.
✓ Branch 15 taken 376 times.
✓ Branch 16 taken 3010 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 3010 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
2196940 if(water > 0 && ((get_bit(quest_rules,qr_DROWN) && z==0 && fakez==0 && fall>=0 && fakefall>=0) || CanSideSwim()) && !ladderx && hoverclk==0 && action!=rafting && !inlikelike && !DRIEDLAKE)
23587 {
23588
4/8
✓ Branch 0 taken 3000 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 3000 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3000 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3010 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
23589 {
23590
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(!(ladderx+laddery)) drownCombo = water;
23591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (combobuf[water].usrflags&cflag1) Drown(1);
23592 10 else Drown();
23593
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
10 if(byte drown_sfx = combobuf[water].attribytes[4])
23594 8 sfx(drown_sfx, pan(int32_t(x)));
23595 10 }
23596
2/2
✓ Branch 0 taken 2891 times.
✓ Branch 1 taken 109 times.
3000 else if (!isSwimming())
23597 {
23598 109 SetSwim();
23599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if (!IsSideSwim()) attackclk = charging = spins = 0;
23600 109 landswim=0;
23601 109 return;
23602 }
23603 2901 }
23604
23605
23606
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 2196668 times.
2196831 if(type==cSTEP)
23607 {
23608 //zprint2("Hero.HasHeavyBoots(): is: %s\n", ( (Hero.HasHeavyBoots()) ? "true" : "false" ));
23609
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 66 times.
163 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepnext)
23610 {
23611 66 stepnext=((ty+8)&0xF0)+((tx+8)>>4);
23612
23613 if
23614 (
23615
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 4 times.
66 COMBOTYPE(tx+8,ty+8)==cSTEP && /*required item*/
23616
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 (!combobuf[tmpscr->data[stepnext]].attribytes[1] || (combobuf[tmpscr->data[stepnext]].attribytes[1] && game->item[combobuf[tmpscr->data[stepnext]].attribytes[1]]) )
23617 && /*HEAVY*/
23618
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
23619 )
23620
23621 {
23622 62 sfx(combobuf[tmpscr->data[stepnext]].attribytes[0],pan((int32_t)x));
23623 62 tmpscr->data[stepnext]++;
23624
23625 62 }
23626
23627 if
23628 (
23629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 COMBOTYPE(tx+8,ty+8)==cSTEPSAME && /*required item*/
23630 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
23631 && /*HEAVY*/
23632 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
23633 )
23634 {
23635 int32_t stepc = tmpscr->data[stepnext];
23636 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
23637 for(int32_t k=0; k<176; k++)
23638 {
23639 if(tmpscr->data[k]==stepc)
23640 {
23641 tmpscr->data[k]++;
23642 }
23643 }
23644 }
23645
23646 if
23647 (
23648
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 63 times.
66 COMBOTYPE(tx+8,ty+8)==cSTEPALL && /*required item*/
23649
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
23650 && /*HEAVY*/
23651
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
23652 )
23653 {
23654 3 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
23655
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
531 for(int32_t k=0; k<176; k++)
23656 {
23657 if(
23658
3/4
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 507 times.
1050 (combobuf[tmpscr->data[k]].type==cSTEP)||
23659
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 (combobuf[tmpscr->data[k]].type==cSTEPSAME)||
23660
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 6 times.
528 (combobuf[tmpscr->data[k]].type==cSTEPALL)||
23661 522 (combobuf[tmpscr->data[k]].type==cSTEPCOPY)
23662 )
23663 {
23664 21 tmpscr->data[k]++;
23665 21 }
23666 528 }
23667 3 }
23668 66 }
23669 163 }
23670
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2196668 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2196668 else if(type==cSTEPSFX && action == walking)
23671 {
23672 trigger_stepfx(0, COMBOPOS(tx+8,ty+8), true);
23673 }
23674 2196668 else stepnext = -1;
23675
23676 2196831 detail_int[0]=tx;
23677 2196831 detail_int[1]=ty;
23678
23679
23680
8/8
✓ Branch 0 taken 2196603 times.
✓ Branch 1 taken 228 times.
✓ Branch 2 taken 342 times.
✓ Branch 3 taken 2196489 times.
✓ Branch 4 taken 2195682 times.
✓ Branch 5 taken 807 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 8 times.
2196844 if(!((type==cCAVE || type==cCAVE2) && z==0 && fakez==0) && type!=cSTAIR &&
23681
5/6
✓ Branch 0 taken 2195570 times.
✓ Branch 1 taken 112 times.
✓ Branch 2 taken 2195559 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 2195559 times.
✗ Branch 5 not taken.
2195682 type!=cPIT && type!=cSWIMWARP && type!=cRESET &&
23682
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 2195546 times.
2195559 !(type==cDIVEWARP && isDiving()))
23683 2195554 {
23684 RaftingStuff:
23685
2/2
✓ Branch 0 taken 2194995 times.
✓ Branch 1 taken 559 times.
2195554 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
23686 {
23687 559 bool doraft = true;
23688
4/6
✓ Branch 0 taken 559 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 556 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
559 if(((int32_t)y>=raftwarpy-12&&(int32_t)y<=raftwarpy+3)&&raftwarpy!=-1)
23689 {
23690
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
23691 {
23692 3 doraft = false;
23693 3 }
23694 3 }
23695 //if (mfRAFT)
23696 int32_t rafttypes[2];
23697 559 int32_t raftx1 = tx+6;
23698 559 int32_t raftx2 = tx+9;
23699 559 int32_t rafty = ty+11;
23700 int32_t raftflags[3];
23701 559 rafttypes[0]=rafttypes[1]=-1;
23702 559 raftflags[0]=raftflags[1]=raftflags[2]=0;
23703 559 rafttypes[0] = MAPFLAG(raftx1,rafty);
23704 559 rafttypes[1] = MAPFLAG(raftx2,rafty);
23705
23706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
23707 559 raftflags[0] = rafttypes[0];
23708
23709
23710 559 rafttypes[0] = MAPCOMBOFLAG(raftx1,rafty);
23711 559 rafttypes[1] = MAPCOMBOFLAG(raftx2,rafty);
23712
23713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
23714 559 raftflags[1] = rafttypes[0];
23715
23716 559 rafttypes[0] = MAPFFCOMBOFLAG(raftx1,rafty);
23717 559 rafttypes[1] = MAPFFCOMBOFLAG(raftx2,rafty);
23718
23719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
23720 559 raftflags[2] = rafttypes[0];
23721
23722
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 559 times.
2236 for (int32_t m = 0; m < 3; ++m)
23723 {
23724
2/4
✓ Branch 0 taken 1677 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1677 times.
1677 if (raftflags[m] == mfRAFT || raftflags[m] == mfRAFT_BRANCH)
23725 {
23726 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && (combo_class_buf[COMBOTYPE(tx+8, ty+11)].dock || combo_class_buf[FFCOMBOTYPE(tx+8, ty+11)].dock))
23727 {
23728 if((isRaftFlag(nextflag(tx,ty+11,dir,false))||isRaftFlag(nextflag(tx,ty+11,dir,true))))
23729 {
23730 reset_swordcharge();
23731 action=rafting; FFCore.setHeroAction(rafting);
23732 raftclk=0;
23733 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23734 else sfx(tmpscr->secretsfx);
23735 }
23736 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
23737 {
23738 for (int32_t i = 0; i < 4; ++i)
23739 {
23740 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,true)))
23741 {
23742 reset_swordcharge();
23743 action=rafting; FFCore.setHeroAction(rafting);
23744 raftclk=0;
23745 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23746 else sfx(tmpscr->secretsfx);
23747 dir = i;
23748 break;
23749 }
23750 }
23751 }
23752 }
23753 }
23754 1677 }
23755 559 }
23756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2195554 times.
2195554 if (RaftPass) return;
23757
3/3
✓ Branch 0 taken 10772 times.
✓ Branch 1 taken 2184376 times.
✓ Branch 2 taken 406 times.
2195554 switch(flag)
23758 {
23759 case mfDIVE_ITEM:
23760
6/8
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 397 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
406 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
23761 {
23762 12 additem(x, y, tmpscr->catchall,
23763 6 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
23764 6 sfx(tmpscr->secretsfx);
23765 6 }
23766
23767 406 return;
23768
23769 case mfRAFT:
23770 case mfRAFT_BRANCH:
23771
23772 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
23773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10772 times.
10772 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
23774 {
23775 10772 bool doraft = true;
23776
5/6
✓ Branch 0 taken 10772 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 948 times.
✓ Branch 3 taken 9824 times.
✓ Branch 4 taken 122 times.
✓ Branch 5 taken 826 times.
10772 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
23777 {
23778
5/6
✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 392 times.
✓ Branch 3 taken 434 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 374 times.
826 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
23779 {
23780 374 doraft = false;
23781 374 }
23782 826 }
23783
13/16
✓ Branch 0 taken 9636 times.
✓ Branch 1 taken 1136 times.
✓ Branch 2 taken 1924 times.
✓ Branch 3 taken 7712 times.
✓ Branch 4 taken 1914 times.
✓ Branch 5 taken 10 times.
✓ Branch 6 taken 1911 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 1911 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1911 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1911 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1262 times.
✓ Branch 15 taken 649 times.
10772 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
23784 {
23785
3/4
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 178 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 471 times.
649 if(isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true)))
23786 {
23787 178 reset_swordcharge();
23788 178 action=rafting; FFCore.setHeroAction(rafting);
23789 178 raftclk=0;
23790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23791 178 else sfx(tmpscr->secretsfx);
23792 178 }
23793
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 471 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
471 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
23794 {
23795 for (int32_t i = 0; i < 4; ++i)
23796 {
23797 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
23798 {
23799 reset_swordcharge();
23800 action=rafting; FFCore.setHeroAction(rafting);
23801 raftclk=0;
23802 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23803 else sfx(tmpscr->secretsfx);
23804 dir = i;
23805 break;
23806 }
23807 }
23808 }
23809 649 }
23810 10772 }
23811
23812 10772 return;
23813
23814 default:
23815 2184376 break;
23816 //return;
23817 }
23818
23819
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2184376 times.
✗ Branch 2 not taken.
2184376 switch(flag2)
23820 {
23821 case mfDIVE_ITEM:
23822 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
23823 {
23824 additem(x, y, tmpscr->catchall,
23825 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
23826 sfx(tmpscr->secretsfx);
23827 }
23828
23829 return;
23830
23831 case mfRAFT:
23832 case mfRAFT_BRANCH:
23833
23834 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
23835 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
23836 {
23837 bool doraft = true;
23838 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
23839 {
23840 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
23841 {
23842 doraft = false;
23843 }
23844 }
23845 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
23846 {
23847 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
23848 {
23849 reset_swordcharge();
23850 action=rafting; FFCore.setHeroAction(rafting);
23851 raftclk=0;
23852 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23853 else sfx(tmpscr->secretsfx);
23854 }
23855 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
23856 {
23857 for (int32_t i = 0; i < 4; ++i)
23858 {
23859 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
23860 {
23861 reset_swordcharge();
23862 action=rafting; FFCore.setHeroAction(rafting);
23863 raftclk=0;
23864 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23865 else sfx(tmpscr->secretsfx);
23866 dir = i;
23867 break;
23868 }
23869 }
23870 }
23871 }
23872 }
23873
23874 return;
23875
23876 default:
23877 2184376 break;
23878 //return;
23879 }
23880
23881
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2184376 times.
✗ Branch 2 not taken.
2184376 switch(flag3)
23882 {
23883 case mfDIVE_ITEM:
23884 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
23885 {
23886 additem(x, y, tmpscr->catchall,
23887 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
23888 sfx(tmpscr->secretsfx);
23889 }
23890
23891 return;
23892
23893 case mfRAFT:
23894 case mfRAFT_BRANCH:
23895
23896 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
23897 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
23898 {
23899 bool doraft = true;
23900 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
23901 {
23902 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
23903 {
23904 doraft = false;
23905 }
23906 }
23907 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
23908 {
23909 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
23910 {
23911 reset_swordcharge();
23912 action=rafting; FFCore.setHeroAction(rafting);
23913 raftclk=0;
23914 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23915 else sfx(tmpscr->secretsfx);
23916 }
23917 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
23918 {
23919 for (int32_t i = 0; i < 4; ++i)
23920 {
23921 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
23922 {
23923 reset_swordcharge();
23924 action=rafting; FFCore.setHeroAction(rafting);
23925 raftclk=0;
23926 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23927 else sfx(tmpscr->secretsfx);
23928 dir = i;
23929 break;
23930 }
23931 }
23932 }
23933 }
23934 }
23935
23936 return;
23937
23938 default:
23939 2184376 return;
23940 }
23941 }
23942
23943
23944 1277 int32_t t=(currscr<128)?0:1;
23945
23946
3/4
✓ Branch 0 taken 1049 times.
✓ Branch 1 taken 228 times.
✓ Branch 2 taken 1277 times.
✗ Branch 3 not taken.
1277 if((type==cCAVE || type==cCAVE2) && (tmpscr[t].tilewarptype[index]==wtNOWARP)) return;
23947
23948 //don't do this for canceled warps -DD
23949 //I have no idea why we do this skip, but I'll dutifully propagate it to all cases below...
23950 /*if(tmpscr[t].tilewarptype[index] != wtNOWARP)
23951 {
23952 draw_screen(tmpscr);
23953 advanceframe(true);
23954 }*/
23955
23956 1277 bool skippedaframe=false;
23957
23958
6/6
✓ Branch 0 taken 1049 times.
✓ Branch 1 taken 228 times.
✓ Branch 2 taken 935 times.
✓ Branch 3 taken 114 times.
✓ Branch 4 taken 807 times.
✓ Branch 5 taken 128 times.
1277 if(type==cCAVE || type==cCAVE2 || type==cSTAIR)
23959 {
23960 // Stop music only if:
23961 // * entering a Guy Cave
23962 // * warping to a DMap whose music is different.
23963
23964 1149 int32_t tdm = tmpscr[t].tilewarpdmap[index];
23965
23966
2/2
✓ Branch 0 taken 734 times.
✓ Branch 1 taken 415 times.
1149 if(tmpscr[t].tilewarptype[index]<=wtPASS)
23967 {
23968
3/4
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 339 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 395 times.
734 if((DMaps[currdmap].flags&dmfCAVES) && tmpscr[t].tilewarptype[index] == wtCAVE)
23969 395 music_stop();
23970 734 }
23971 else
23972 {
23973
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 405 times.
415 if(zcmusic!=NULL)
23974 {
23975
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
20 if(strcmp(zcmusic->filename, DMaps[tdm].tmusic) != 0 ||
23976
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 (zcmusic->type==ZCMF_GME && zcmusic->track!=DMaps[tdm].tmusictrack))
23977 10 music_stop();
23978 10 }
23979
3/4
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 352 times.
405 else if(DMaps[tmpscr->tilewarpdmap[index]].midi != (currmidi-ZC_MIDI_COUNT+4) &&
23980 352 TheMaps[(DMaps[tdm].map*MAPSCRS + (tmpscr[t].tilewarpscr[index] + DMaps[tdm].xoff))].screen_midi != (currmidi-ZC_MIDI_COUNT+4))
23981 352 music_stop();
23982 }
23983
23984 1149 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
23985
5/6
✓ Branch 0 taken 734 times.
✓ Branch 1 taken 415 times.
✓ Branch 2 taken 395 times.
✓ Branch 3 taken 339 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 395 times.
1149 bool opening = (tmpscr[t].tilewarptype[index]<=wtPASS && !(DMaps[currdmap].flags&dmfCAVES && tmpscr[t].tilewarptype[index]==wtCAVE)
23986 810 ? false : COOLSCROLL);
23987
23988 1149 FFCore.warpScriptCheck();
23989 1149 draw_screen(tmpscr);
23990 1149 advanceframe(true);
23991
23992 1149 skippedaframe=true;
23993
23994
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 1035 times.
1149 if(type==cCAVE2) walkup2(opening);
23995
2/2
✓ Branch 0 taken 807 times.
✓ Branch 1 taken 228 times.
1035 else if(type==cCAVE) walkdown(opening);
23996 1149 }
23997
23998
2/2
✓ Branch 0 taken 1165 times.
✓ Branch 1 taken 112 times.
1277 if(type==cPIT)
23999 {
24000 112 didpit=true;
24001 112 pitx=x;
24002 112 pity=y;
24003 112 warp_sound = warpsfx2;
24004 112 }
24005
24006
5/6
✓ Branch 0 taken 695 times.
✓ Branch 1 taken 582 times.
✓ Branch 2 taken 639 times.
✓ Branch 3 taken 56 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 56 times.
1333 if(DMaps[currdmap].flags&dmf3STAIR && (currscr==129 || !(DMaps[currdmap].flags&dmfGUYCAVES))
24007
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
695 && tmpscr[specialcave > 0 && DMaps[currdmap].flags&dmfGUYCAVES ? 1:0].room==rWARP && type==cSTAIR)
24008 {
24009
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(!skippedaframe)
24010 {
24011 FFCore.warpScriptCheck();
24012 draw_screen(tmpscr);
24013 advanceframe(true);
24014 }
24015
24016 // "take any road you want"
24017
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 11 times.
56 int32_t dw = x<112 ? 1 : (x>136 ? 3 : 2);
24018 56 int32_t code = WARPCODE(currdmap,homescr,dw);
24019
24020
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(code>-1)
24021 {
24022 56 bool changedlevel = false;
24023 56 bool changeddmap = false;
24024
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 15 times.
56 if(currdmap != code>>8)
24025 {
24026 15 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
24027 15 changeddmap = true;
24028 15 }
24029
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(dlevel != DMaps[code>>8].level)
24030 {
24031 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
24032 changedlevel = true;
24033 }
24034 56 currdmap = code>>8;
24035 56 dlevel = DMaps[currdmap].level;
24036
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 15 times.
56 if(changeddmap)
24037 {
24038 15 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
24039 15 }
24040
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(changedlevel)
24041 {
24042 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
24043 }
24044
24045 56 currmap = DMaps[currdmap].map;
24046 56 homescr = (code&0xFF) + DMaps[currdmap].xoff;
24047 56 init_dmap();
24048
24049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(canPermSecret())
24050 56 setmapflag(mSECRET);
24051 56 }
24052
24053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(specialcave==STAIRCAVE) exitcave();
24054
24055 56 return;
24056 }
24057
24058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1221 times.
1221 if(type==cRESET)
24059 {
24060 if(!skippedaframe)
24061 {
24062 FFCore.warpScriptCheck();
24063 draw_screen(tmpscr);
24064 advanceframe(true);
24065 }
24066
24067 if(!(tmpscr->noreset&mSECRET)) unsetmapflag(mSECRET);
24068
24069 if(!(tmpscr->noreset&mITEM)) unsetmapflag(mITEM);
24070
24071 if(!(tmpscr->noreset&mSPECIALITEM)) unsetmapflag(mSPECIALITEM);
24072
24073 if(!(tmpscr->noreset&mNEVERRET)) unsetmapflag(mNEVERRET);
24074
24075 if(!(tmpscr->noreset&mCHEST)) unsetmapflag(mCHEST);
24076
24077 if(!(tmpscr->noreset&mLOCKEDCHEST)) unsetmapflag(mLOCKEDCHEST);
24078
24079 if(!(tmpscr->noreset&mBOSSCHEST)) unsetmapflag(mBOSSCHEST);
24080
24081 if(!(tmpscr->noreset&mLOCKBLOCK)) unsetmapflag(mLOCKBLOCK);
24082
24083 if(!(tmpscr->noreset&mBOSSLOCKBLOCK)) unsetmapflag(mBOSSLOCKBLOCK);
24084
24085 if(isdungeon())
24086 {
24087 if(!(tmpscr->noreset&mDOOR_LEFT)) unsetmapflag(mDOOR_LEFT);
24088
24089 if(!(tmpscr->noreset&mDOOR_RIGHT)) unsetmapflag(mDOOR_RIGHT);
24090
24091 if(!(tmpscr->noreset&mDOOR_DOWN)) unsetmapflag(mDOOR_DOWN);
24092
24093 if(!(tmpscr->noreset&mDOOR_UP)) unsetmapflag(mDOOR_UP);
24094 }
24095
24096 didpit=true;
24097 pitx=x;
24098 pity=y;
24099 sdir=dir;
24100 dowarp(4,0, warpsfx2);
24101 }
24102 else
24103 {
24104
3/4
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 1093 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
1221 if(!skippedaframe && (tmpscr[t].tilewarptype[index]!=wtNOWARP))
24105 {
24106 128 FFCore.warpScriptCheck();
24107 128 draw_screen(tmpscr);
24108 128 advanceframe(true);
24109 128 }
24110
24111 1221 sdir = dir;
24112 1221 dowarp(0,index, warpsfx2);
24113 }
24114 6404512 }
24115
24116 67 int32_t selectWlevel(int32_t d)
24117 {
24118
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(TriforceCount()==0)
24119 return 0;
24120
24121 67 word l = game->get_wlevel();
24122
24123 67 do
24124 {
24125
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
121 if(d==0 && (game->lvlitems[l+1] & liTRIFORCE))
24126 break;
24127
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 52 times.
121 else if(d<0)
24128
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 11 times.
52 l = (l==0) ? 7 : l-1;
24129 else
24130
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 58 times.
69 l = (l==7) ? 0 : l+1;
24131
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 67 times.
121 }
24132 121 while(!(game->lvlitems[l+1] & liTRIFORCE));
24133
24134 67 game->set_wlevel(l);
24135 67 return l;
24136 67 }
24137
24138 // Would someone tell the Dodongos to shut their yaps?!
24139 11408 void kill_enemy_sfx()
24140 {
24141
2/2
✓ Branch 0 taken 11408 times.
✓ Branch 1 taken 21237 times.
32645 for(int32_t i=0; i<guys.Count(); i++)
24142 {
24143
2/2
✓ Branch 0 taken 7628 times.
✓ Branch 1 taken 13609 times.
21237 if(((enemy*)guys.spr(i))->bgsfx)
24144 13609 stop_sfx(((enemy*)guys.spr(i))->bgsfx);
24145 21237 }
24146
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 11342 times.
11408 if (Hero.action!=inwind) stop_sfx(WAV_ZN1WHIRLWIND);
24147
2/2
✓ Branch 0 taken 11395 times.
✓ Branch 1 taken 13 times.
11408 if(tmpscr->room==rGANON)
24148 13 stop_sfx(WAV_ROAR);
24149 11408 }
24150
24151 555 bool HeroClass::HasHeavyBoots()
24152 {
24153
2/2
✓ Branch 0 taken 555 times.
✓ Branch 1 taken 142080 times.
142635 for ( int32_t q = 0; q < MAXITEMS; ++q )
24154 {
24155
5/6
✓ Branch 0 taken 1665 times.
✓ Branch 1 taken 140415 times.
✓ Branch 2 taken 555 times.
✓ Branch 3 taken 1110 times.
✓ Branch 4 taken 555 times.
✗ Branch 5 not taken.
142080 if ( game->item[q] && ( itemsbuf[q].family == itype_boots ) && /*iron*/ (itemsbuf[q].flags&ITEM_FLAG2) ) return true;
24156 142080 }
24157 555 return false;
24158 555 }
24159
24160 const char *roomtype_string[rMAX] =
24161 {
24162 "(None)","Special Item","Pay for Info","Secret Money","Gamble",
24163 "Door Repair","Red Potion or Heart Container","Feed the Goriya","Triforce Check",
24164 "Potion Shop","Shop","More Bombs","Leave Money or Life","10 Rupees",
24165 "3-Stair Warp","Ganon","Zelda", "-<item pond>", "1/2 Magic Upgrade", "Learn Slash", "More Arrows","Take One Item"
24166 };
24167
24168 2121 bool HeroClass::dowarp(int32_t type, int32_t index, int32_t warpsfx)
24169 {
24170 2121 byte reposition_sword_postwarp = 0;
24171
1/2
✓ Branch 0 taken 2121 times.
✗ Branch 1 not taken.
2121 if(index<0)
24172 {
24173 return false;
24174 }
24175 2121 is_warping = true;
24176
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 2121 times.
2303 for ( int32_t q = 0; q < Lwpns.Count(); ++q )
24177 {
24178 182 weapon *swd=NULL;
24179 182 swd = (weapon*)Lwpns.spr(q);
24180
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 8 times.
182 if(swd->id == (attack==wSword ? wSword : wWand))
24181 {
24182 8 Lwpns.del(q);
24183 8 }
24184 182 }
24185
24186 2121 attackclk = charging = spins = tapping = 0;
24187 2121 attack = none;
24188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2121 times.
2121 if ( warp_sound > 0 ) warpsfx = warp_sound;
24189 2121 warp_sound = 0;
24190 2121 word wdmap=0;
24191 2121 byte wscr=0,wtype=0,t=0;
24192 2121 bool overlay=false;
24193 2121 t=(currscr<128)?0:1;
24194 2121 int32_t wrindex = 0;
24195 2121 bool wasSideview = isSideViewGravity(t); // (tmpscr[t].flags7 & fSIDEVIEW)!=0 && !ignoreSideview;
24196
24197 // Drawing commands probably shouldn't carry over...
24198
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2056 times.
2121 if ( !get_bit(quest_rules,qr_SCRIPTDRAWSINWARPS) )
24199 2056 script_drawing_commands.Clear();
24200
24201
4/6
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 1224 times.
✓ Branch 2 taken 766 times.
✓ Branch 3 taken 66 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2121 switch(type)
24202 {
24203 case 0: // tile warp
24204 1224 wtype = tmpscr[t].tilewarptype[index];
24205 1224 wdmap = tmpscr[t].tilewarpdmap[index];
24206 1224 wscr = tmpscr[t].tilewarpscr[index];
24207 1224 overlay = get_bit(&tmpscr[t].tilewarpoverlayflags,index)?1:0;
24208 1224 wrindex=(tmpscr->warpreturnc>>(index*2))&3;
24209 1224 break;
24210
24211 case 1: // side warp
24212 766 wtype = tmpscr[t].sidewarptype[index];
24213 766 wdmap = tmpscr[t].sidewarpdmap[index];
24214 766 wscr = tmpscr[t].sidewarpscr[index];
24215 766 overlay = get_bit(&tmpscr[t].sidewarpoverlayflags,index)?1:0;
24216 766 wrindex=(tmpscr->warpreturnc>>(8+(index*2)))&3;
24217 //tmpscr->doscript = 0; //kill the currebt screen's script so that it does not continue to run during the scroll.
24218 //there is no doscript for screen scripts. They run like ffcs.
24219
24220 766 break;
24221
24222 case 2: // whistle warp
24223 {
24224 66 wtype = wtWHISTLE;
24225
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 int32_t wind = whistleitem>-1 ? itemsbuf[whistleitem].misc2 : 8;
24226 66 int32_t level=0;
24227
24228
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(blowcnt==0)
24229 level = selectWlevel(0);
24230 else
24231 {
24232
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 66 times.
133 for(int32_t i=0; i<abs(blowcnt); i++)
24233 67 level = selectWlevel(blowcnt);
24234 }
24235
24236
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
66 if(level > QMisc.warp[wind].size && QMisc.warp[wind].size>0)
24237 {
24238 level %= QMisc.warp[wind].size;
24239 game->set_wlevel(level);
24240 }
24241
24242 66 wdmap = QMisc.warp[wind].dmap[level];
24243 66 wscr = QMisc.warp[wind].scr[level];
24244 }
24245 66 break;
24246
24247 case 3:
24248 wtype = wtIWARP;
24249 wdmap = cheat_goto_dmap;
24250 wscr = cheat_goto_screen;
24251 break;
24252
24253 case 4:
24254 wtype = wtIWARP;
24255 wdmap = currdmap;
24256 wscr = homescr-DMaps[currdmap].xoff;
24257 break;
24258 }
24259
24260 2121 bool intradmap = (wdmap == currdmap);
24261 2121 int32_t olddmap = currdmap;
24262 2121 rehydratelake(type!=wtSCROLL);
24263
24264
7/8
✓ Branch 0 taken 691 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 450 times.
✓ Branch 3 taken 228 times.
✓ Branch 4 taken 423 times.
✓ Branch 5 taken 249 times.
✓ Branch 6 taken 66 times.
✓ Branch 7 taken 14 times.
2121 switch(wtype)
24265 {
24266 case wtCAVE:
24267 {
24268 // cave/item room
24269 450 ALLOFF();
24270 450 homescr=currscr;
24271 450 currscr=0x80;
24272
24273
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 111 times.
450 if(DMaps[currdmap].flags&dmfCAVES) // cave
24274 {
24275 339 music_stop();
24276 339 kill_sfx();
24277
24278
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 278 times.
339 if(tmpscr->room==rWARP)
24279 {
24280 61 currscr=0x81;
24281 61 specialcave = STAIRCAVE;
24282 61 }
24283 278 else specialcave = GUYCAVE;
24284
24285 //lighting(2,dir);
24286 339 lighting(false, true);
24287 339 loadlvlpal(10);
24288
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 38 times.
640 bool b2 = COOLSCROLL&&
24289
3/4
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 106 times.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
301 ((combobuf[MAPCOMBO(x,y-16)].type==cCAVE)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2)||
24290
2/4
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
195 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEB)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2B)||
24291
2/4
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
195 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEC)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2C)||
24292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 195 times.
195 (combobuf[MAPCOMBO(x,y-16)].type==cCAVED)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2D));
24293 339 blackscr(30,b2?false:true);
24294 339 loadscr(0,wdmap,currscr,up,false);
24295 339 loadscr(1,wdmap,homescr,up,false);
24296 //preloaded freeform combos
24297 339 ffscript_engine(true);
24298 339 putscr(scrollbuf,0,0,tmpscr);
24299 339 putscrdoors(scrollbuf,0,0,tmpscr);
24300 339 dir=up;
24301 339 x=112;
24302 339 y=160;
24303
1/2
✓ Branch 0 taken 339 times.
✗ Branch 1 not taken.
339 if(didpit)
24304 {
24305 didpit=false;
24306 x=pitx;
24307 y=pity;
24308 }
24309
24310 339 reset_hookshot();
24311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339 times.
339 if(reposition_sword_postwarp)
24312 {
24313 weapon *swd=NULL;
24314 for(int32_t i=0; i<Lwpns.Count(); i++)
24315 {
24316 swd = (weapon*)Lwpns.spr(i);
24317
24318 if(swd->id == (attack==wSword ? wSword : wWand))
24319 {
24320 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24321 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24322 positionSword(swd,item_id);
24323 break;
24324 }
24325 }
24326 }
24327 339 stepforward(diagonalMovement?5:6, false);
24328 339 }
24329 else // item room
24330 {
24331 111 specialcave = ITEMCELLAR;
24332 111 map_bkgsfx(false);
24333 111 kill_enemy_sfx();
24334 111 draw_screen(tmpscr,false);
24335
24336 //unless the room is already dark, fade to black
24337
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 110 times.
111 if(!darkroom)
24338 {
24339 110 darkroom = true;
24340 110 fade(DMaps[currdmap].color,true,false);
24341 110 }
24342
24343 111 blackscr(30,true);
24344 111 loadscr(0,wdmap,currscr,down,false);
24345 111 loadscr(1,wdmap,homescr,-1,false);
24346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if ( dontdraw < 2 ) { dontdraw=1; }
24347 111 draw_screen(tmpscr);
24348 111 fade(11,true,true);
24349 111 darkroom = false;
24350 111 dir=down;
24351 111 x=48;
24352 111 y=0;
24353
24354 // is this didpit check necessary?
24355
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(didpit)
24356 {
24357 didpit=false;
24358 x=pitx;
24359 y=pity;
24360 }
24361
24362 111 reset_hookshot();
24363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(reposition_sword_postwarp)
24364 {
24365 weapon *swd=NULL;
24366 for(int32_t i=0; i<Lwpns.Count(); i++)
24367 {
24368 swd = (weapon*)Lwpns.spr(i);
24369
24370 if(swd->id == (attack==wSword ? wSword : wWand))
24371 {
24372 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24373 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24374 positionSword(swd,item_id);
24375 break;
24376 }
24377 }
24378 }
24379 111 lighting(false, true);
24380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if ( dontdraw < 2 ) { dontdraw=0; }
24381 111 stepforward(diagonalMovement?16:18, false);
24382 }
24383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 450 times.
450 if (get_bit(quest_rules,qr_SCREEN80_OWN_MUSIC)) playLevelMusic();
24384 450 break;
24385 }
24386
24387 case wtPASS: // passageway
24388 {
24389 228 map_bkgsfx(false);
24390 228 kill_enemy_sfx();
24391 228 ALLOFF();
24392 //play sound
24393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
24394 228 homescr=currscr;
24395 228 currscr=0x81;
24396 228 specialcave = PASSAGEWAY;
24397 228 byte warpscr2 = wscr + DMaps[wdmap].xoff;
24398 228 draw_screen(tmpscr,false);
24399
24400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if(!get_bit(quest_rules, qr_NEW_DARKROOM))
24401 {
24402
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 220 times.
228 if(!darkroom)
24403 220 fade(DMaps[currdmap].color,true,false);
24404
24405 228 darkroom=true;
24406 228 }
24407 228 blackscr(30,true);
24408 228 loadscr(0,wdmap,currscr,down,false);
24409 228 loadscr(1,wdmap,homescr,-1,false);
24410 //preloaded freeform combos
24411 228 ffscript_engine(true);
24412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if ( dontdraw < 2 ) { dontdraw=1; }
24413 228 draw_screen(tmpscr);
24414 228 lighting(false, true);
24415 228 dir=down;
24416 228 x=48;
24417
24418
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 117 times.
228 if((homescr&15) > (warpscr2&15))
24419 {
24420 117 x=192;
24421 117 }
24422
24423
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4 times.
228 if((homescr&15) == (warpscr2&15))
24424 {
24425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((currscr>>4) > (warpscr2>>4))
24426 {
24427 4 x=192;
24428 4 }
24429 4 }
24430
24431 // is this didpit check necessary?
24432
1/2
✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
228 if(didpit)
24433 {
24434 didpit=false;
24435 x=pitx;
24436 y=pity;
24437 }
24438
24439 228 y=0;
24440 228 set_respawn_point();
24441 228 trySideviewLadder();
24442 228 reset_hookshot();
24443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if(reposition_sword_postwarp)
24444 {
24445 weapon *swd=NULL;
24446 for(int32_t i=0; i<Lwpns.Count(); i++)
24447 {
24448 swd = (weapon*)Lwpns.spr(i);
24449
24450 if(swd->id == (attack==wSword ? wSword : wWand))
24451 {
24452 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24453 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24454 positionSword(swd,item_id);
24455 break;
24456 }
24457 }
24458 }
24459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if ( dontdraw < 2 ) { dontdraw=0; }
24460 228 stepforward(diagonalMovement?16:18, false);
24461 228 newscr_clk=frame;
24462 228 activated_timed_warp=false;
24463 228 stepoutindex=index;
24464 228 stepoutscr = warpscr2;
24465 228 stepoutdmap = wdmap;
24466 228 stepoutwr=wrindex;
24467 }
24468 228 break;
24469
24470 case wtEXIT: // entrance/exit
24471 {
24472 423 lighting(false,false,pal_litRESETONLY);//Reset permLit, and do nothing else; lighting was not otherwise called on a wtEXIT warp.
24473 423 ALLOFF();
24474 423 music_stop();
24475 423 kill_sfx();
24476 423 blackscr(30,false);
24477 423 bool changedlevel = false;
24478 423 bool changeddmap = false;
24479
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 422 times.
423 if(currdmap != wdmap)
24480 {
24481 422 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
24482 422 changeddmap = true;
24483 422 }
24484
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 405 times.
423 if(dlevel != DMaps[wdmap].level)
24485 {
24486 405 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
24487 405 changedlevel = true;
24488 405 }
24489 423 dlevel = DMaps[wdmap].level;
24490 423 currdmap = wdmap;
24491
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 422 times.
423 if(changeddmap)
24492 {
24493 422 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
24494 422 }
24495
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 405 times.
423 if(changedlevel)
24496 {
24497 405 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
24498 405 }
24499
24500 423 currmap=DMaps[currdmap].map;
24501 423 init_dmap();
24502 423 update_subscreens(wdmap);
24503 423 loadfullpal();
24504 423 ringcolor(false);
24505 423 loadlvlpal(DMaps[currdmap].color);
24506 //lastentrance_dmap = currdmap;
24507 423 homescr = currscr = wscr + DMaps[currdmap].xoff;
24508 423 loadscr(0,currdmap,currscr,-1,overlay);
24509
24510
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 420 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
423 if((tmpscr->flags&fDARK) && !get_bit(quest_rules,qr_NEW_DARKROOM))
24511 {
24512
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(quest_rules,qr_FADE))
24513 {
24514 interpolatedfade();
24515 }
24516 else
24517 {
24518 3 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
24519 }
24520
24521 3 darkroom=naturaldark=true;
24522 3 }
24523 else
24524 {
24525 420 darkroom=naturaldark=false;
24526 }
24527
24528 int32_t wrx,wry;
24529
24530
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 409 times.
423 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
24531 {
24532 14 wrx=tmpscr->warpreturnx[0];
24533 14 wry=tmpscr->warpreturny[0];
24534 14 }
24535 else
24536 {
24537 409 wrx=tmpscr->warparrivalx;
24538 409 wry=tmpscr->warparrivaly;
24539 }
24540
24541
6/6
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 355 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 371 times.
423 if(((wrx>0||wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
24542 {
24543
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 141 times.
371 if(dlevel)
24544 {
24545 230 lastentrance = currscr;
24546 230 }
24547 else
24548 {
24549 141 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
24550 }
24551
24552 371 lastentrance_dmap = wdmap;
24553 371 }
24554
24555
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 193 times.
423 if(dlevel)
24556 {
24557
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 223 times.
230 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
24558 {
24559 7 x=tmpscr->warpreturnx[wrindex];
24560 7 y=tmpscr->warpreturny[wrindex];
24561 7 }
24562 else
24563 {
24564 223 x=tmpscr->warparrivalx;
24565 223 y=tmpscr->warparrivaly;
24566 }
24567 230 }
24568 else
24569 {
24570 193 x=tmpscr->warpreturnx[wrindex];
24571 193 y=tmpscr->warpreturny[wrindex];
24572 }
24573
24574
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 4 times.
423 if(didpit)
24575 {
24576 4 didpit=false;
24577 4 x=pitx;
24578 4 y=pity;
24579 4 }
24580
24581 423 dir=down;
24582
24583
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 407 times.
423 if(x==0) dir=right;
24584
24585
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 412 times.
423 if(x==240) dir=left;
24586
24587
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 409 times.
423 if(y==0) dir=down;
24588
24589
2/2
✓ Branch 0 taken 171 times.
✓ Branch 1 taken 252 times.
423 if(y==160) dir=up;
24590
24591
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 193 times.
423 if(dlevel)
24592 {
24593 // reset enemy kill counts
24594
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 230 times.
29670 for(int32_t i=0; i<128; i++)
24595 {
24596 29440 game->guys[(currmap*MAPSCRSNORMAL)+i] = 0;
24597 29440 game->maps[(currmap*MAPSCRSNORMAL)+i] &= ~mTMPNORET;
24598 29440 }
24599 230 }
24600
24601 423 markBmap(dir^1);
24602 //preloaded freeform combos
24603 423 ffscript_engine(true);
24604
24605 423 reset_hookshot();
24606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
423 if(reposition_sword_postwarp)
24607 {
24608 weapon *swd=NULL;
24609 for(int32_t i=0; i<Lwpns.Count(); i++)
24610 {
24611 swd = (weapon*)Lwpns.spr(i);
24612
24613 if(swd->id == (attack==wSword ? wSword : wWand))
24614 {
24615 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24616 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24617 positionSword(swd,item_id);
24618 break;
24619 }
24620 }
24621 }
24622
24623
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 266 times.
423 if(isdungeon())
24624 {
24625 157 openscreen();
24626
3/4
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 123 times.
157 if(get_bit(extra_rules, er_SHORTDGNWALK)==0 && get_bit(quest_rules, qr_SHORTDGNWALK)==0)
24627 123 stepforward(diagonalMovement?11:12, false);
24628 else
24629 // Didn't walk as far pre-1.93, and some quests depend on that
24630 34 stepforward(8, false);
24631 157 }
24632 else
24633 {
24634
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 243 times.
266 if(!COOLSCROLL)
24635 23 openscreen();
24636
24637 266 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type; // Old-style blue square placement
24638 266 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
24639 266 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type; // More old-style blue square placement
24640
24641
5/10
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 88 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 178 times.
✓ Branch 4 taken 178 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 178 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
266 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
24642 {
24643 88 reset_pal_cycling();
24644 88 putscr(scrollbuf,0,0,tmpscr);
24645 88 putscrdoors(scrollbuf,0,0,tmpscr);
24646 88 walkup(COOLSCROLL);
24647 88 }
24648
5/10
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 175 times.
✓ Branch 4 taken 175 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 175 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
178 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
24649 {
24650 3 reset_pal_cycling();
24651 3 putscr(scrollbuf,0,0,tmpscr);
24652 3 putscrdoors(scrollbuf,0,0,tmpscr);
24653 3 walkdown2(COOLSCROLL);
24654 3 }
24655
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 13 times.
175 else if(COOLSCROLL)
24656 {
24657 162 openscreen();
24658 162 }
24659 }
24660
24661 423 show_subscreen_life=true;
24662 423 show_subscreen_numbers=true;
24663 423 playLevelMusic();
24664 423 currcset=DMaps[currdmap].color;
24665 423 dointro();
24666 423 set_respawn_point();
24667 423 trySideviewLadder();
24668
24669
2/2
✓ Branch 0 taken 2538 times.
✓ Branch 1 taken 423 times.
2961 for(int32_t i=0; i<6; i++)
24670 2538 visited[i]=-1;
24671
24672 423 break;
24673 }
24674
24675 case wtSCROLL: // scrolling warp
24676 {
24677 249 int32_t c = DMaps[currdmap].color;
24678 249 scrolling_map = currmap;
24679 249 currmap = DMaps[wdmap].map;
24680 249 update_subscreens(wdmap);
24681
24682 249 dlevel = DMaps[wdmap].level;
24683 //check if Hero has the map for the new location before updating the subscreen. ? -Z
24684 //This works only in one direction, if Hero had a map, to not having one.
24685 //If Hero does not have a map, and warps somewhere where he does, then the map still briefly shows.
24686 249 update_subscreens(wdmap);
24687
24688 /*if ( has_item(itype_map, dlevel) )
24689 {
24690 //Blank the map during an intra-dmap scrolling warp.
24691 dlevel = -1; //a hack for the minimap. This works!! -Z
24692 }*/
24693
24694 // fix the scrolling direction, if it was a tile or instant warp
24695
2/4
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
249 if(type==0 || type>=3)
24696 {
24697 sdir = dir;
24698 }
24699
24700 249 scrollscr(sdir, wscr+DMaps[wdmap].xoff, wdmap);
24701 //dlevel = DMaps[wdmap].level; //Fix dlevel and draw the map (end hack). -Z
24702
24703 249 reset_hookshot();
24704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
249 if(reposition_sword_postwarp)
24705 {
24706 weapon *swd=NULL;
24707 for(int32_t i=0; i<Lwpns.Count(); i++)
24708 {
24709 swd = (weapon*)Lwpns.spr(i);
24710
24711 if(swd->id == (attack==wSword ? wSword : wWand))
24712 {
24713 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24714 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24715 positionSword(swd,item_id);
24716 break;
24717 }
24718 }
24719 }
24720
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 203 times.
249 if(!intradmap)
24721 {
24722 203 homescr = currscr = wscr + DMaps[wdmap].xoff;
24723 203 init_dmap();
24724
24725 int32_t wrx,wry;
24726
24727
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 99 times.
203 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
24728 {
24729 104 wrx=tmpscr->warpreturnx[0];
24730 104 wry=tmpscr->warpreturny[0];
24731 104 }
24732 else
24733 {
24734 99 wrx=tmpscr->warparrivalx;
24735 99 wry=tmpscr->warparrivaly;
24736 }
24737
24738
7/8
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 102 times.
✓ Branch 2 taken 101 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 129 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 68 times.
203 if(((wrx>0||wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))&&(!get_bit(quest_rules,qr_NOSCROLLCONTINUE))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
24739 {
24740
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 48 times.
68 if(dlevel)
24741 {
24742 20 lastentrance = currscr;
24743 20 }
24744 else
24745 {
24746 48 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
24747 }
24748
24749 68 lastentrance_dmap = wdmap;
24750 68 }
24751 203 }
24752
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 114 times.
249 if(DMaps[currdmap].color != c)
24753 {
24754 114 lighting(false, true);
24755 114 }
24756
24757 249 playLevelMusic();
24758 249 currcset=DMaps[currdmap].color;
24759 249 dointro();
24760 }
24761 249 break;
24762
24763 case wtWHISTLE: // whistle warp
24764 {
24765 66 scrolling_map = currmap;
24766 66 currmap = DMaps[wdmap].map;
24767 66 scrollscr(index, wscr+DMaps[wdmap].xoff, wdmap);
24768 66 reset_hookshot();
24769 66 currdmap=wdmap;
24770 66 dlevel=DMaps[currdmap].level;
24771 66 lighting(false, true);
24772 66 init_dmap();
24773
24774 66 playLevelMusic();
24775 66 currcset=DMaps[currdmap].color;
24776 66 dointro();
24777 66 action=inwind; FFCore.setHeroAction(inwind);
24778 int32_t wry;
24779
24780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
24781 wry=tmpscr->warpreturny[0];
24782 66 else wry=tmpscr->warparrivaly;
24783
24784 int32_t wrx;
24785
24786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
24787 wrx=tmpscr->warpreturnx[0];
24788 66 else wrx=tmpscr->warparrivalx;
24789
24790
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 66 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 66 times.
✓ Branch 10 taken 66 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 66 times.
✗ Branch 13 not taken.
132 Lwpns.add(new weapon((zfix)(index==left?240:index==right?0:wrx),(zfix)(index==down?0:index==up?160:wry),
24791
2/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
66 (zfix)0,wWind,1,0,index,whistleitem,getUID(),false,false,true,1));
24792 66 whirlwind=255;
24793 66 whistleitem=-1;
24794 }
24795 66 break;
24796
24797 case wtIWARP:
24798 case wtIWARPBLK:
24799 case wtIWARPOPEN:
24800 case wtIWARPZAP:
24801 case wtIWARPWAVE: // insta-warps
24802 {
24803 691 bool old_192 = false;
24804
1/2
✓ Branch 0 taken 691 times.
✗ Branch 1 not taken.
691 if (get_bit(quest_rules,qr_192b163_WARP))
24805 {
24806 if ( wtype == wtIWARPWAVE )
24807 {
24808 wtype = wtIWARPWAVE;
24809 old_192 = true;
24810 }
24811 if ( old_192 )
24812 {
24813 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Wave Warp.\n %s\n", "Trying to redirect it into a Cancel Effect");
24814 didpit=false;
24815 update_subscreens();
24816 warp_sound = 0;
24817 is_warping = false;
24818 return false;
24819 }
24820 }
24821 //for determining whether to exit cave
24822 691 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
24823 691 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
24824 691 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
24825
24826
8/8
✓ Branch 0 taken 617 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 596 times.
✓ Branch 4 taken 617 times.
✓ Branch 5 taken 21 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 604 times.
1337 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
24827
8/8
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 592 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 604 times.
✓ Branch 6 taken 592 times.
✓ Branch 7 taken 12 times.
617 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
24828
24829
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 626 times.
775 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
24830 {
24831 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
24832 626 bool wasswimming = (action == swimming);
24833 626 int32_t olddiveclk = diveclk;
24834 626 ALLOFF();
24835
24836
2/2
✓ Branch 0 taken 608 times.
✓ Branch 1 taken 18 times.
626 if(wasswimming)
24837 {
24838 18 Hero.SetSwim();
24839 18 diveclk = olddiveclk;
24840 18 }
24841
24842 626 kill_sfx();
24843 626 }
24844 //play sound
24845
2/2
✓ Branch 0 taken 583 times.
✓ Branch 1 taken 42 times.
627 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
24846
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 556 times.
625 if(wtype==wtIWARPZAP)
24847 {
24848 69 zapout();
24849 69 }
24850
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 518 times.
556 else if(wtype==wtIWARPWAVE)
24851 {
24852 //only draw Hero if he's not in a cave -DD
24853 38 wavyout(!cavewarp);
24854 38 }
24855
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 176 times.
518 else if(wtype!=wtIWARP)
24856 {
24857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
176 bool b2 = COOLSCROLL&&cavewarp;
24858 176 blackscr(30,b2?false:true);
24859 176 }
24860
24861 625 int32_t c = DMaps[currdmap].color;
24862 625 bool changedlevel = false;
24863 625 bool changeddmap = false;
24864
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 369 times.
625 if(currdmap != wdmap)
24865 {
24866 369 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
24867 369 changeddmap = true;
24868 369 }
24869
2/2
✓ Branch 0 taken 459 times.
✓ Branch 1 taken 166 times.
625 if(dlevel != DMaps[wdmap].level)
24870 {
24871 166 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
24872 166 changedlevel = true;
24873 166 }
24874 625 dlevel = DMaps[wdmap].level;
24875 625 currdmap = wdmap;
24876
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 369 times.
625 if(changeddmap)
24877 {
24878 369 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
24879 369 }
24880
2/2
✓ Branch 0 taken 459 times.
✓ Branch 1 taken 166 times.
625 if(changedlevel)
24881 {
24882 166 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
24883 166 }
24884
24885 625 currmap = DMaps[currdmap].map;
24886 625 init_dmap();
24887 625 update_subscreens(wdmap);
24888
24889 625 ringcolor(false);
24890
24891
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 270 times.
625 if(DMaps[currdmap].color != c)
24892 270 loadlvlpal(DMaps[currdmap].color);
24893
24894 625 homescr = currscr = wscr + DMaps[currdmap].xoff;
24895
24896 625 lightingInstant(); // Also sets naturaldark
24897
24898 625 loadscr(0,currdmap,currscr,-1,overlay);
24899
24900 625 x = tmpscr->warpreturnx[wrindex];
24901 625 y = tmpscr->warpreturny[wrindex];
24902
24903
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 237 times.
625 if(didpit)
24904 {
24905 237 didpit=false;
24906 237 x=pitx;
24907 237 y=pity;
24908 237 }
24909
24910 625 type1 = combobuf[MAPCOMBO(x,y-16)].type;
24911 625 type2 = combobuf[MAPCOMBO(x,y)].type;
24912 625 type3 = combobuf[MAPCOMBO(x,y+16)].type;
24913
24914
2/2
✓ Branch 0 taken 551 times.
✓ Branch 1 taken 74 times.
625 if(x==0) dir=right;
24915
24916
2/2
✓ Branch 0 taken 623 times.
✓ Branch 1 taken 2 times.
625 if(x==240) dir=left;
24917
24918
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 24 times.
625 if(y==0) dir=down;
24919
24920
2/2
✓ Branch 0 taken 596 times.
✓ Branch 1 taken 29 times.
625 if(y==160) dir=up;
24921
24922 625 markBmap(dir^1);
24923
24924 625 int32_t checkwater = iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+(bigHitbox?8:12)); //iswaterex can be intensive, so let's avoid as many calls as we can.
24925
24926
10/16
✓ Branch 0 taken 611 times.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 14 times.
✓ Branch 12 taken 14 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14 times.
✓ Branch 15 taken 611 times.
639 if(checkwater && _walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) && current_item(itype_flippers) > 0 && current_item(itype_flippers) >= combobuf[checkwater].attribytes[0] && (!(combobuf[checkwater].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
24927 {
24928 14 hopclk=0xFF;
24929 14 SetSwim();
24930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (!IsSideSwim()) attackclk = charging = spins = 0;
24931 14 }
24932 else
24933 {
24934 611 action = none; FFCore.setHeroAction(none);
24935 }
24936 //preloaded freeform combos
24937 625 ffscript_engine(true);
24938
24939 625 putscr(scrollbuf,0,0,tmpscr);
24940 625 putscrdoors(scrollbuf,0,0,tmpscr);
24941
24942
10/10
✓ Branch 0 taken 621 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 597 times.
✓ Branch 4 taken 621 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 23 times.
✓ Branch 7 taken 598 times.
✓ Branch 8 taken 42 times.
✓ Branch 9 taken 65 times.
625 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
24943 {
24944 94 reset_pal_cycling();
24945 94 putscr(scrollbuf,0,0,tmpscr);
24946 94 putscrdoors(scrollbuf,0,0,tmpscr);
24947 94 walkup(COOLSCROLL);
24948 94 }
24949
9/10
✓ Branch 0 taken 621 times.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 600 times.
✓ Branch 4 taken 621 times.
✓ Branch 5 taken 21 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 600 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 21 times.
663 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
24950 {
24951 84 reset_pal_cycling();
24952 84 putscr(scrollbuf,0,0,tmpscr);
24953 84 putscrdoors(scrollbuf,0,0,tmpscr);
24954 84 walkdown2(COOLSCROLL);
24955 84 }
24956
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 551 times.
621 else if(wtype==wtIWARPZAP)
24957 {
24958 70 zapin();
24959 70 }
24960
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 513 times.
551 else if(wtype==wtIWARPWAVE)
24961 {
24962 38 wavyin();
24963 38 }
24964
2/2
✓ Branch 0 taken 430 times.
✓ Branch 1 taken 83 times.
513 else if(wtype==wtIWARPOPEN)
24965 {
24966 83 openscreen();
24967 83 }
24968
1/2
✓ Branch 0 taken 715 times.
✗ Branch 1 not taken.
715 if(reposition_sword_postwarp)
24969 {
24970 weapon *swd=NULL;
24971 for(int32_t i=0; i<Lwpns.Count(); i++)
24972 {
24973 swd = (weapon*)Lwpns.spr(i);
24974
24975 if(swd->id == (attack==wSword ? wSword : wWand))
24976 {
24977 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24978 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24979 positionSword(swd,item_id);
24980 break;
24981 }
24982 }
24983 }
24984 715 show_subscreen_life=true;
24985 715 show_subscreen_numbers=true;
24986 715 playLevelMusic();
24987 715 currcset=DMaps[currdmap].color;
24988 715 dointro();
24989 715 set_respawn_point();
24990 715 trySideviewLadder();
24991 }
24992 715 break;
24993
24994
24995 case wtNOWARP:
24996 {
24997 14 bool old_192 = false;
24998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (get_bit(quest_rules,qr_192b163_WARP))
24999 {
25000 wtype = wtIWARPWAVE;
25001 old_192 = true;
25002 }
25003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if ( old_192 )
25004 {
25005 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Cancel Warp.\n %s\n", "Trying to redirect it into a Wave Effect");
25006 //for determining whether to exit cave
25007 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
25008 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
25009 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
25010
25011 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
25012 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
25013
25014 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
25015 {
25016 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
25017 bool wasswimming = (action == swimming);
25018 int32_t olddiveclk = diveclk;
25019 ALLOFF();
25020
25021 if(wasswimming)
25022 {
25023 Hero.SetSwim();
25024 diveclk = olddiveclk;
25025 }
25026
25027 kill_sfx();
25028 }
25029 //play sound
25030 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
25031 if(wtype==wtIWARPZAP)
25032 {
25033 zapout();
25034 }
25035 else if(wtype==wtIWARPWAVE)
25036 {
25037 //only draw Hero if he's not in a cave -DD
25038 wavyout(!cavewarp);
25039 }
25040 else if(wtype!=wtIWARP)
25041 {
25042 bool b2 = COOLSCROLL&&cavewarp;
25043 blackscr(30,b2?false:true);
25044 }
25045
25046 int32_t c = DMaps[currdmap].color;
25047 bool changedlevel = false;
25048 bool changeddmap = false;
25049 if(currdmap != wdmap)
25050 {
25051 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
25052 changeddmap = true;
25053 }
25054 if(dlevel != DMaps[wdmap].level)
25055 {
25056 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
25057 changedlevel = true;
25058 }
25059 dlevel = DMaps[wdmap].level;
25060 currdmap = wdmap;
25061 if(changeddmap)
25062 {
25063 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
25064 }
25065 if(changedlevel)
25066 {
25067 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
25068 }
25069 currmap = DMaps[currdmap].map;
25070 init_dmap();
25071 update_subscreens(wdmap);
25072
25073 ringcolor(false);
25074
25075 if(DMaps[currdmap].color != c)
25076 loadlvlpal(DMaps[currdmap].color);
25077
25078 homescr = currscr = wscr + DMaps[currdmap].xoff;
25079
25080 lightingInstant(); // Also sets naturaldark
25081
25082 loadscr(0,currdmap,currscr,-1,overlay);
25083
25084 x = tmpscr->warpreturnx[wrindex];
25085 y = tmpscr->warpreturny[wrindex];
25086
25087 if(didpit)
25088 {
25089 didpit=false;
25090 x=pitx;
25091 y=pity;
25092 }
25093
25094 type1 = combobuf[MAPCOMBO(x,y-16)].type;
25095 type2 = combobuf[MAPCOMBO(x,y)].type;
25096 type3 = combobuf[MAPCOMBO(x,y+16)].type;
25097
25098 if(x==0) dir=right;
25099
25100 if(x==240) dir=left;
25101
25102 if(y==0) dir=down;
25103
25104 if(y==160) dir=up;
25105
25106 markBmap(dir^1);
25107
25108 if(iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+8) && _walkflag(x,y+8,0,SWITCHBLOCK_STATE) && current_item(itype_flippers))
25109 {
25110 hopclk=0xFF;
25111 SetSwim();
25112 if (!IsSideSwim()) attackclk = charging = spins = 0;
25113 }
25114 else
25115 {
25116 action = none;
25117 FFCore.setHeroAction(none);
25118 }
25119 //preloaded freeform combos
25120 ffscript_engine(true);
25121
25122 putscr(scrollbuf,0,0,tmpscr);
25123 putscrdoors(scrollbuf,0,0,tmpscr);
25124
25125 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
25126 {
25127 reset_pal_cycling();
25128 putscr(scrollbuf,0,0,tmpscr);
25129 putscrdoors(scrollbuf,0,0,tmpscr);
25130 walkup(COOLSCROLL);
25131 }
25132 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
25133 {
25134 reset_pal_cycling();
25135 putscr(scrollbuf,0,0,tmpscr);
25136 putscrdoors(scrollbuf,0,0,tmpscr);
25137 walkdown2(COOLSCROLL);
25138 }
25139 else if(wtype==wtIWARPZAP)
25140 {
25141 zapin();
25142 }
25143 else if(wtype==wtIWARPWAVE)
25144 {
25145 wavyin();
25146 }
25147 else if(wtype==wtIWARPOPEN)
25148 {
25149 openscreen();
25150 }
25151 if(reposition_sword_postwarp)
25152 {
25153 weapon *swd=NULL;
25154 for(int32_t i=0; i<Lwpns.Count(); i++)
25155 {
25156 swd = (weapon*)Lwpns.spr(i);
25157
25158 if(swd->id == (attack==wSword ? wSword : wWand))
25159 {
25160 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25161 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25162 positionSword(swd,item_id);
25163 break;
25164 }
25165 }
25166 }
25167 show_subscreen_life=true;
25168 show_subscreen_numbers=true;
25169 playLevelMusic();
25170 currcset=DMaps[currdmap].color;
25171 dointro();
25172 set_respawn_point();
25173 trySideviewLadder();
25174 break;
25175 }
25176 else
25177 {
25178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(reposition_sword_postwarp)
25179 {
25180 weapon *swd=NULL;
25181 for(int32_t i=0; i<Lwpns.Count(); i++)
25182 {
25183 swd = (weapon*)Lwpns.spr(i);
25184
25185 if(swd->id == (attack==wSword ? wSword : wWand))
25186 {
25187 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25188 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25189 positionSword(swd,item_id);
25190 break;
25191 }
25192 }
25193 }
25194 14 didpit=false;
25195 14 update_subscreens();
25196 14 warp_sound = 0;
25197 14 is_warping = false;
25198 14 return false;
25199 }
25200 }
25201 default:
25202 didpit=false;
25203 update_subscreens();
25204 warp_sound = 0;
25205 is_warping = false;
25206 if(reposition_sword_postwarp)
25207 {
25208 weapon *swd=NULL;
25209 for(int32_t i=0; i<Lwpns.Count(); i++)
25210 {
25211 swd = (weapon*)Lwpns.spr(i);
25212
25213 if(swd->id == (attack==wSword ? wSword : wWand))
25214 {
25215 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25216 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25217 positionSword(swd,item_id);
25218 break;
25219 }
25220 }
25221 }
25222 return false;
25223 }
25224
25225
25226
25227 // Stop Hero from drowning!
25228
5/6
✓ Branch 0 taken 2041 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 2041 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✓ Branch 5 taken 1951 times.
2131 if(action==drowning || action==lavadrowning || action==sidedrowning)
25229 {
25230 180 drownclk=0;
25231 180 drownclk=0;
25232 180 action=none; FFCore.setHeroAction(none);
25233 180 }
25234
25235 1951 int32_t checkwater = iswaterex(MAPCOMBO(x,y+(bigHitbox?8:12)), currmap, currscr, -1, x,y+(bigHitbox?8:12));
25236 // But keep him swimming if he ought to be!
25237 // Unless the water is too high levelled, in which case... well, he'll drown on transition probably anyways. -Dimi
25238
9/12
✓ Branch 0 taken 2035 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 2007 times.
✓ Branch 3 taken 28 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 28 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 28 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 28 times.
✓ Branch 10 taken 2110 times.
✓ Branch 11 taken 17 times.
1979 if(action!=rafting && checkwater && (_walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) || get_bit(quest_rules,qr_DROWN))
25239 //&& (current_item(itype_flippers) >= combobuf[checkwater].attribytes[0])
25240
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
28 && (action!=inwind))
25241 {
25242 17 hopclk=0xFF;
25243 17 SetSwim();
25244 17 }
25245
25246 2127 newscr_clk=frame;
25247 2127 activated_timed_warp=false;
25248 2127 eat_buttons();
25249
25250
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 1699 times.
2127 if(wtype!=wtIWARP)
25251 1699 attackclk=0;
25252
25253 2127 didstuff=0;
25254 2127 usecounts.clear();
25255 2127 map_bkgsfx(true);
25256 2127 loadside=dir^1;
25257 2127 whistleclk=-1;
25258
25259
3/4
✓ Branch 0 taken 2041 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 2131 times.
✗ Branch 3 not taken.
2127 if((z>0 || fakez>0) && isSideViewHero())
25260 {
25261 y-=z;
25262 y-=fakez;
25263 fakez=0;
25264 z=0;
25265 }
25266
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 1925 times.
2131 else if(!isSideViewHero())
25267 {
25268 1925 fall=0;
25269 1925 fakefall=0;
25270 1925 }
25271
25272 // If warping between top-down and sideview screens,
25273 // fix enemies that are carried over by Full Screen Warp
25274 2131 const bool tmpscr_is_sideview = isSideViewHero();
25275
25276
4/4
✓ Branch 0 taken 1928 times.
✓ Branch 1 taken 203 times.
✓ Branch 2 taken 1898 times.
✓ Branch 3 taken 30 times.
2131 if(!wasSideview && tmpscr_is_sideview)
25277 {
25278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 for(int32_t i=0; i<guys.Count(); i++)
25279 {
25280 if(guys.spr(i)->z > 0 || guys.spr(i)->fakez > 0)
25281 {
25282 guys.spr(i)->y -= guys.spr(i)->z;
25283 guys.spr(i)->y -= guys.spr(i)->fakez;
25284 guys.spr(i)->z = 0;
25285 guys.spr(i)->fakez = 0;
25286 }
25287
25288 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
25289 guys.spr(i)->yofs += 2;
25290 }
25291 30 }
25292
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 1988 times.
✓ Branch 2 taken 86 times.
✓ Branch 3 taken 27 times.
2101 else if(wasSideview && !tmpscr_is_sideview)
25293 {
25294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 for(int32_t i=0; i<guys.Count(); i++)
25295 {
25296 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
25297 guys.spr(i)->yofs -= 2;
25298 }
25299 27 }
25300
25301
6/6
✓ Branch 0 taken 1347 times.
✓ Branch 1 taken 784 times.
✓ Branch 2 taken 275 times.
✓ Branch 3 taken 1072 times.
✓ Branch 4 taken 206 times.
✓ Branch 5 taken 73 times.
2131 if((DMaps[currdmap].type&dmfCONTINUE) || (currdmap==0&&get_bit(quest_rules, qr_DMAP_0_CONTINUE_BUG)))
25302 {
25303
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 726 times.
990 if(dlevel)
25304 {
25305 int32_t wrx,wry;
25306
25307
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 213 times.
240 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
25308 {
25309 27 wrx=tmpscr->warpreturnx[0];
25310 27 wry=tmpscr->warpreturny[0];
25311 27 }
25312 else
25313 {
25314 213 wrx=tmpscr->warparrivalx;
25315 213 wry=tmpscr->warparrivaly;
25316 }
25317
25318
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
240 if((wtype == wtEXIT)
25319
7/10
✓ Branch 0 taken 184 times.
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 173 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
240 || (((wtype == wtSCROLL) && !intradmap) && ((wrx>0 || wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))))
25320 {
25321
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
63 if(!(wtype==wtSCROLL)||!(get_bit(quest_rules,qr_NOSCROLLCONTINUE)))
25322 {
25323 63 game->set_continue_scrn(homescr);
25324 //Z_message("continue_scrn = %02X e/e\n",game->get_continue_scrn());
25325 63 }
25326 else if(currdmap != game->get_continue_dmap())
25327 {
25328 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
25329 }
25330 63 }
25331 else
25332 {
25333
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 22 times.
177 if(currdmap != game->get_continue_dmap())
25334 {
25335 22 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
25336 //Z_message("continue_scrn = %02X dlevel\n",game->get_continue_scrn());
25337 22 }
25338 }
25339 240 }
25340 else
25341 {
25342 726 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
25343 //Z_message("continue_scrn = %02X\n !dlevel\n",game->get_continue_scrn());
25344 }
25345
25346 966 game->set_continue_dmap(currdmap);
25347 966 lastentrance_dmap = currdmap;
25348 966 lastentrance = game->get_continue_scrn();
25349 //Z_message("continue_map = %d\n",game->get_continue_dmap());
25350 966 }
25351
25352
1/2
✓ Branch 0 taken 2111 times.
✗ Branch 1 not taken.
2111 if(tmpscr->flags4&fAUTOSAVE)
25353 {
25354 save_game(true,0);
25355 }
25356
25357
2/2
✓ Branch 0 taken 2099 times.
✓ Branch 1 taken 12 times.
2111 if(tmpscr->flags6&fCONTINUEHERE)
25358 {
25359 12 lastentrance_dmap = currdmap;
25360 12 lastentrance = homescr;
25361 12 }
25362
25363 2111 update_subscreens();
25364 2111 verifyBothWeapons();
25365
25366
2/2
✓ Branch 0 taken 1661 times.
✓ Branch 1 taken 450 times.
2111 if(wtype==wtCAVE)
25367 {
25368
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 111 times.
450 if(DMaps[currdmap].flags&dmfGUYCAVES)
25369 678 Z_eventlog("Entered %s containing %s.\n",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar",
25370 339 (char *)moduledata.roomtype_names[tmpscr[1].room]);
25371 else
25372 111 Z_eventlog("Entered %s.",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar");
25373 450 }
25374 3322 else Z_eventlog("Warped to DMap %d: %s, screen %d, via %s.\n", currdmap, DMaps[currdmap].name,currscr,
25375
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 1363 times.
3024 wtype==wtPASS ? "Passageway" :
25376
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 940 times.
2303 wtype==wtEXIT ? "Entrance/Exit" :
25377
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 691 times.
940 wtype==wtSCROLL ? "Scrolling Warp" :
25378 691 wtype==wtWHISTLE ? "Whistle Warp" :
25379 "Insta-Warp");
25380
25381 2111 eventlog_mapflags();
25382
1/2
✓ Branch 0 taken 2111 times.
✗ Branch 1 not taken.
2111 if(reposition_sword_postwarp)
25383 {
25384 weapon *swd=NULL;
25385 for(int32_t i=0; i<Lwpns.Count(); i++)
25386 {
25387 swd = (weapon*)Lwpns.spr(i);
25388
25389 if(swd->id == (attack==wSword ? wSword : wWand))
25390 {
25391 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25392 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25393 positionSword(swd,item_id);
25394 break;
25395 }
25396 }
25397 }
25398 2111 FFCore.init_combo_doscript();
25399
4/4
✓ Branch 0 taken 895 times.
✓ Branch 1 taken 1216 times.
✓ Branch 2 taken 825 times.
✓ Branch 3 taken 70 times.
2111 if (!intradmap || get_bit(quest_rules, qr_WARPS_RESTART_DMAPSCRIPT))
25400 {
25401 2041 FFScript::deallocateAllArrays(SCRIPT_DMAP, olddmap);
25402 2041 FFCore.initZScriptDMapScripts();
25403 2041 FFCore.initZScriptActiveSubscreenScript();
25404 2041 }
25405 2111 is_warping = false;
25406 2111 return true;
25407 2125 }
25408
25409 289 void HeroClass::exitcave()
25410 {
25411 289 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
25412 289 currscr=homescr;
25413 289 loadscr(0,currdmap,currscr,255,false); // bogus direction
25414 289 x = tmpscr->warpreturnx[0];
25415 289 y = tmpscr->warpreturny[0];
25416
25417
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 if(didpit)
25418 {
25419 didpit=false;
25420 x=pitx;
25421 y=pity;
25422 }
25423
25424
2/2
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 15 times.
289 if(x+y == 0)
25425 15 x = y = 80;
25426
25427 289 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
25428 289 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
25429 289 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
25430
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 268 times.
577 bool b = COOLSCROLL &&
25431
4/4
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 191 times.
268 ((type1==cCAVE) || (type1>=cCAVEB && type1<=cCAVED) ||
25432
4/4
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 191 times.
191 (type2==cCAVE) || (type2>=cCAVEB && type2<=cCAVED) ||
25433
4/4
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 173 times.
191 (type3==cCAVE2) || (type3>=cCAVE2B && type3<=cCAVE2D) ||
25434
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 178 times.
✓ Branch 2 taken 173 times.
✓ Branch 3 taken 5 times.
173 (type2==cCAVE2) || (type2>=cCAVE2B && type2<=cCAVE2D));
25435 309 ALLOFF();
25436 309 blackscr(30,b?false:true);
25437 309 ringcolor(false);
25438 309 loadlvlpal(DMaps[currdmap].color);
25439 309 lighting(false, true);
25440 309 music_stop();
25441 309 kill_sfx();
25442 309 putscr(scrollbuf,0,0,tmpscr);
25443 309 putscrdoors(scrollbuf,0,0,tmpscr);
25444
25445
9/10
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 211 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 206 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
309 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
25446 {
25447 104 walkup(COOLSCROLL);
25448 104 }
25449
9/10
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 188 times.
✓ Branch 4 taken 193 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 188 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
211 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
25450 {
25451 18 walkdown2(COOLSCROLL);
25452 18 }
25453
25454 315 show_subscreen_life=true;
25455 315 show_subscreen_numbers=true;
25456 315 playLevelMusic();
25457 315 currcset=DMaps[currdmap].color;
25458 315 dointro();
25459 315 newscr_clk=frame;
25460 315 activated_timed_warp=false;
25461 315 dir=down;
25462 315 set_respawn_point();
25463 315 eat_buttons();
25464 315 didstuff=0;
25465 315 usecounts.clear();
25466 315 map_bkgsfx(true);
25467 315 loadside=dir^1;
25468 315 }
25469
25470
25471 5782 void HeroClass::stepforward(int32_t steps, bool adjust)
25472 {
25473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5782 times.
5782 if ( FFCore.nostepforward ) return;
25474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5782 times.
5782 if ( FFCore.temp_no_stepforward ) { FFCore.temp_no_stepforward = 0; return; }
25475 5782 zfix tx=x; //temp x
25476 5782 zfix ty=y; //temp y
25477 5782 zfix tstep(0); //temp single step distance
25478 5782 zfix s(0); //calculated step distance for all steps
25479 5782 z3step=2;
25480 5782 int32_t sh=shiftdir;
25481 5782 shiftdir=-1;
25482
25483
2/2
✓ Branch 0 taken 98930 times.
✓ Branch 1 taken 5782 times.
104712 for(int32_t i=steps; i>0; --i)
25484 {
25485
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 98919 times.
98930 if(diagonalMovement)
25486 {
25487
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
25488 {
25489 11 tstep = 1.5;
25490 11 }
25491 else
25492 {
25493 tstep=z3step;
25494 z3step=(z3step%2)+1;
25495 }
25496 11 }
25497 else
25498 {
25499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98919 times.
98919 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT))
25500 {
25501 tstep = 1.5;
25502 }
25503 else
25504 {
25505
2/2
✓ Branch 0 taken 55695 times.
✓ Branch 1 taken 43224 times.
98919 tstep=lsteps[int32_t((dir<left)?ty:tx)&7];
25506
25507
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 31390 times.
✓ Branch 2 taken 24305 times.
✓ Branch 3 taken 19261 times.
✓ Branch 4 taken 23963 times.
98919 switch(dir)
25508 {
25509 case up:
25510 31390 ty-=tstep;
25511 31390 break;
25512
25513 case down:
25514 24305 ty+=tstep;
25515 24305 break;
25516
25517 case left:
25518 19261 tx-=tstep;
25519 19261 break;
25520
25521 case right:
25522 23963 tx+=tstep;
25523 23963 break;
25524 }
25525 }
25526 }
25527
25528 98930 s+=tstep;
25529 98930 }
25530
25531 5782 z3step=2;
25532
25533 5782 x = x.getInt();
25534 5782 y = y.getInt();
25535
2/2
✓ Branch 0 taken 104616 times.
✓ Branch 1 taken 5782 times.
110398 while(s>=0)
25536 {
25537
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 104604 times.
104616 if(diagonalMovement)
25538 {
25539
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
12 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
25540 {
25541 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
25542 {
25543 walkable = false;
25544 shiftdir = -1;
25545 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
25546 switch(tdir)
25547 {
25548 case left:
25549 --x;
25550 break;
25551 case right:
25552 ++x;
25553 break;
25554 case up:
25555 --y;
25556 break;
25557 case down:
25558 ++y;
25559 break;
25560 }
25561 }
25562 else
25563 {
25564 walkable=false;
25565 shiftdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
25566 moveOld2(dir, 150);
25567 }
25568 }
25569 else
25570 {
25571
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
25572 {
25573 12 s-=1.5;
25574 12 }
25575 else
25576 {
25577 s-=z3step;
25578 }
25579 12 walkable=true;
25580 12 moveOld2(dir, 150);
25581 }
25582
25583 12 shiftdir=-1;
25584 12 }
25585 else
25586 {
25587
3/6
✓ Branch 0 taken 58977 times.
✓ Branch 1 taken 45627 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104604 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104604 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
25588 {
25589 walkable=false;
25590 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
25591 switch(tdir)
25592 {
25593 case left:
25594 --x;
25595 break;
25596 case right:
25597 ++x;
25598 break;
25599 case up:
25600 --y;
25601 break;
25602 case down:
25603 ++y;
25604 break;
25605 }
25606 }
25607 else
25608 {
25609
2/4
✓ Branch 0 taken 104604 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104604 times.
104604 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
25610 {
25611 s-=1.5;
25612 }
25613
2/2
✓ Branch 0 taken 58977 times.
✓ Branch 1 taken 45627 times.
104604 else if(dir<left)
25614 {
25615 58977 s-=lsteps[y.getInt()&7];
25616 58977 }
25617 else
25618 {
25619 45627 s-=lsteps[x.getInt()&7];
25620 }
25621
25622 104604 moveOld2(dir, 150);
25623 }
25624 }
25625
25626
2/2
✓ Branch 0 taken 98834 times.
✓ Branch 1 taken 5782 times.
104616 if(s<0)
25627 {
25628 // Not quite sure how this is actually supposed to work.
25629 // There have to be two cases for each direction or Hero
25630 // either walks too far onto the screen or may get stuck
25631 // going through walk-through walls.
25632
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2109 times.
✓ Branch 2 taken 1268 times.
✓ Branch 3 taken 1049 times.
✓ Branch 4 taken 1356 times.
5782 switch(dir)
25633 {
25634 case up:
25635
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 1973 times.
2109 if(y<8) // Leaving the screen
25636 136 y+=s;
25637 else // Entering the screen
25638 1973 y-=s;
25639
25640 2109 break;
25641
25642 case down:
25643
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 1153 times.
1268 if(y>152)
25644 115 y-=s;
25645 else
25646 1153 y+=s;
25647
25648 1268 break;
25649
25650 case left:
25651
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 948 times.
1049 if(x<8)
25652 101 x+=s;
25653 else
25654 948 x-=s;
25655
25656 1049 break;
25657
25658 case right:
25659
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 1241 times.
1356 if(x>=232)
25660 115 x-=s;
25661 else
25662 1241 x+=s;
25663
25664 1356 break;
25665 }
25666 5782 }
25667
25668
25669 104616 draw_screen(tmpscr);
25670
1/2
✓ Branch 0 taken 104616 times.
✗ Branch 1 not taken.
104616 if (canSideviewLadder()) setOnSideviewLadder(true);
25671 104616 advanceframe(true);
25672
25673
1/2
✓ Branch 0 taken 104616 times.
✗ Branch 1 not taken.
104616 if(Quit)
25674 return;
25675 }
25676
4/4
✓ Branch 0 taken 4426 times.
✓ Branch 1 taken 1356 times.
✓ Branch 2 taken 1268 times.
✓ Branch 3 taken 3158 times.
5782 if(dir==right||dir==down)
25677 {
25678 2624 x=int32_t(x);
25679 2624 y=int32_t(y);
25680 2624 }
25681 else
25682 {
25683 3158 x = x.getInt();
25684 3158 y = y.getInt();
25685 }
25686 5782 set_respawn_point();
25687 5782 draw_screen(tmpscr);
25688 5782 eat_buttons();
25689 5782 shiftdir=sh;
25690 5782 }
25691
25692 228 void HeroClass::walkdown(bool opening) //entering cave
25693 {
25694
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 198 times.
228 if(opening)
25695 {
25696 198 close_black_opening(x+8, y+8+playing_field_offset, false);
25697 198 }
25698
25699 228 hclk=0;
25700 228 stop_item_sfx(itype_brang);
25701 228 sfx(WAV_STAIRS,pan(x.getInt()));
25702 228 clk=0;
25703 // int32_t cmby=(y.getInt()&0xF0)+16;
25704 // Fix Hero's position to the grid
25705 228 y=y.getInt()&0xF0;
25706 228 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
25707 228 attack=wNone;
25708 228 attackid=-1;
25709 228 reset_swordcharge();
25710 228 climb_cover_x=x.getInt()&0xF0;
25711 228 climb_cover_y=(y.getInt()&0xF0)+16;
25712
25713 228 guys.clear();
25714 228 chainlinks.clear();
25715 228 Lwpns.clear();
25716 228 Ewpns.clear();
25717 228 items.clear();
25718
2/2
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 14592 times.
14820 for(int32_t i=0; i<64; i++)
25719 {
25720 14592 herostep();
25721
25722
2/4
✓ Branch 0 taken 14592 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14592 times.
14592 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
25723 hero_count=(hero_count+1)%16;
25724
25725
2/2
✓ Branch 0 taken 10944 times.
✓ Branch 1 taken 3648 times.
14592 if((i&3)==3)
25726 3648 ++y;
25727
25728 14592 draw_screen(tmpscr);
25729 14592 advanceframe(true);
25730
25731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14592 times.
14592 if(Quit)
25732 break;
25733 14592 }
25734
25735 228 action=none; FFCore.setHeroAction(none);
25736 228 }
25737
25738 21 void HeroClass::walkdown2(bool opening) //exiting cave 2
25739 {
25740 21 int32_t type = combobuf[MAPCOMBO(x,y)].type;
25741
25742
25743 // Fix Hero's position to the grid
25744 21 y=y.getInt()&0xF0;
25745
25746
2/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
21 if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
25747 y -= 16;
25748
25749 21 climb_cover_x=x.getInt()&0xF0;
25750 21 climb_cover_y=y.getInt()&0xF0;
25751
25752 21 dir=down;
25753 21 z=fakez=fall=fakefall=0;
25754
25755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(opening)
25756 {
25757 21 open_black_opening(x+8, y+8+playing_field_offset+16, false);
25758 21 }
25759
25760 21 hclk=0;
25761 21 stop_item_sfx(itype_brang);
25762 21 sfx(WAV_STAIRS,pan(x.getInt()));
25763 21 clk=0;
25764 21 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
25765 21 attack=wNone;
25766 21 attackid=-1;
25767 21 reset_swordcharge();
25768
25769 21 guys.clear();
25770 21 chainlinks.clear();
25771 21 Lwpns.clear();
25772 21 Ewpns.clear();
25773 21 items.clear();
25774
25775
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1344 times.
1365 for(int32_t i=0; i<64; i++)
25776 {
25777 1344 herostep();
25778
25779
2/4
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1344 times.
1344 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
25780 hero_count=(hero_count+1)%16;
25781
25782
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 336 times.
1344 if((i&3)==3)
25783 336 ++y;
25784
25785 1344 draw_screen(tmpscr);
25786 1344 advanceframe(true);
25787
25788
1/2
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
1344 if(Quit)
25789 break;
25790 1344 }
25791
25792
25793 21 action=none; FFCore.setHeroAction(none);
25794 21 }
25795
25796 196 void HeroClass::walkup(bool opening) //exiting cave
25797 {
25798 196 int32_t type = combobuf[MAPCOMBO(x,y)].type;
25799
25800
4/6
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 188 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
196 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
25801 y+=16;
25802
25803 // Fix Hero's position to the grid
25804 196 y=y.getInt()&0xF0;
25805 196 z=fakez=fall=fakefall=0;
25806
25807
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 174 times.
196 if(opening)
25808 {
25809 174 open_black_opening(x+8, y+8+playing_field_offset-16, false);
25810 174 }
25811
25812 196 hclk=0;
25813 196 stop_item_sfx(itype_brang);
25814 196 sfx(WAV_STAIRS,pan(x.getInt()));
25815 196 dir=down;
25816 196 clk=0;
25817 // int32_t cmby=y.getInt()&0xF0;
25818 196 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
25819 196 attack=wNone;
25820 196 attackid=-1;
25821 196 reset_swordcharge();
25822 196 climb_cover_x=x.getInt()&0xF0;
25823 196 climb_cover_y=y.getInt()&0xF0;
25824
25825 196 guys.clear();
25826 196 chainlinks.clear();
25827 196 Lwpns.clear();
25828 196 Ewpns.clear();
25829 196 items.clear();
25830
25831
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 12544 times.
12740 for(int32_t i=0; i<64; i++)
25832 {
25833 12544 herostep();
25834
25835
2/4
✓ Branch 0 taken 12544 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12544 times.
12544 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
25836 hero_count=(hero_count+1)%16;
25837
25838
2/2
✓ Branch 0 taken 9408 times.
✓ Branch 1 taken 3136 times.
12544 if((i&3)==0)
25839 3136 --y;
25840
25841 12544 draw_screen(tmpscr);
25842 12544 advanceframe(true);
25843
25844
1/2
✓ Branch 0 taken 12544 times.
✗ Branch 1 not taken.
12544 if(Quit)
25845 break;
25846 12544 }
25847 196 map_bkgsfx(true);
25848 196 loadside=dir^1;
25849 196 action=none; FFCore.setHeroAction(none);
25850 196 }
25851
25852 114 void HeroClass::walkup2(bool opening) //entering cave2
25853 {
25854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(opening)
25855 {
25856 114 close_black_opening(x+8, y+8+playing_field_offset, false);
25857 114 }
25858
25859 114 hclk=0;
25860 114 stop_item_sfx(itype_brang);
25861 114 sfx(WAV_STAIRS,pan(x.getInt()));
25862 114 dir=up;
25863 114 clk=0;
25864 // int32_t cmby=y.getInt()&0xF0;
25865 114 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
25866 114 attack=wNone;
25867 114 attackid=-1;
25868 114 reset_swordcharge();
25869 114 climb_cover_x=x.getInt()&0xF0;
25870 114 climb_cover_y=(y.getInt()&0xF0)-16;
25871
25872 114 guys.clear();
25873 114 chainlinks.clear();
25874 114 Lwpns.clear();
25875 114 Ewpns.clear();
25876 114 items.clear();
25877
25878
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 7296 times.
7410 for(int32_t i=0; i<64; i++)
25879 {
25880 7296 herostep();
25881
25882
2/4
✓ Branch 0 taken 7296 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7296 times.
7296 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
25883 hero_count=(hero_count+1)%16;
25884
25885
2/2
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 1824 times.
7296 if((i&3)==0)
25886 1824 --y;
25887
25888 7296 draw_screen(tmpscr);
25889 7296 advanceframe(true);
25890
25891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7296 times.
7296 if(Quit)
25892 break;
25893 7296 }
25894 114 map_bkgsfx(true);
25895 114 loadside=dir^1;
25896 114 action=none; FFCore.setHeroAction(none);
25897 114 }
25898
25899 325 void HeroClass::stepout() // Step out of item cellars and passageways
25900 {
25901 325 int32_t sc = specialcave; // This gets erased by ALLOFF()
25902 325 ALLOFF();
25903 325 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
25904 325 map_bkgsfx(false);
25905 325 kill_enemy_sfx();
25906 325 draw_screen(tmpscr,false);
25907 325 fade(sc>=GUYCAVE?10:11,true,false);
25908 325 blackscr(30,true);
25909 325 ringcolor(false);
25910
25911
4/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 142 times.
✓ Branch 3 taken 183 times.
325 if(sc==PASSAGEWAY && abs(x-warpx)>16) // How did Hero leave the passageway?
25912 {
25913 183 currdmap=stepoutdmap;
25914 183 currmap=DMaps[currdmap].map;
25915 183 dlevel=DMaps[currdmap].level;
25916
25917 //we might have just left a passage, so be sure to update the CSet record -DD
25918 183 currcset=DMaps[currdmap].color;
25919
25920 183 init_dmap();
25921 183 homescr=stepoutscr;
25922 183 }
25923
25924 325 currscr=homescr;
25925 325 loadscr(0,currdmap,currscr,255,false); // bogus direction
25926 325 draw_screen(tmpscr,false);
25927
25928
3/4
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 319 times.
✓ Branch 3 taken 6 times.
325 if(get_bit(quest_rules, qr_NEW_DARKROOM) || !(tmpscr->flags&fDARK))
25929 {
25930 319 darkroom = naturaldark = false;
25931 319 fade(DMaps[currdmap].color,true,true);
25932 319 }
25933 else
25934 {
25935 6 darkroom = naturaldark = true;
25936
25937
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if(get_bit(quest_rules,qr_FADE))
25938 {
25939 4 interpolatedfade();
25940 4 }
25941 else
25942 {
25943 2 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
25944 }
25945 6 byte *si = colordata + CSET(DMaps[currdmap].color*pdLEVEL+poLEVEL)*3;
25946 6 si+=3*48;
25947
25948
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 6 times.
102 for(int32_t i=0; i<16; i++)
25949 {
25950 96 RAMpal[CSET(9)+i] = _RGB(si);
25951 96 tempgreypal[CSET(9)+i] = _RGB(si); //preserve monochrome
25952 96 si+=3;
25953 96 }
25954 }
25955
25956 325 x = tmpscr->warpreturnx[stepoutwr];
25957 325 y = tmpscr->warpreturny[stepoutwr];
25958
25959
1/2
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
325 if(didpit)
25960 {
25961 didpit=false;
25962 x=pitx;
25963 y=pity;
25964 }
25965
25966
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 309 times.
325 if(x+y == 0)
25967 16 x = y = 80;
25968
25969 325 dir=down;
25970
25971 325 set_respawn_point();
25972
25973 // Let's use the 'exit cave' animation if we entered this cellar via a cave combo.
25974 325 int32_t type = combobuf[MAPCOMBO(tmpscr->warpreturnx[stepoutwr],tmpscr->warpreturny[stepoutwr])].type;
25975
25976
4/6
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 320 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
325 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
25977 {
25978 walkup(false);
25979 }
25980
4/6
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 320 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
325 else if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
25981 {
25982 walkdown2(false);
25983 }
25984
25985 325 newscr_clk=frame;
25986 325 activated_timed_warp=false;
25987 325 didstuff=0;
25988 325 usecounts.clear();
25989 325 eat_buttons();
25990 325 markBmap(-1);
25991 325 map_bkgsfx(true);
25992
25993
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 27 times.
325 if(!get_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC))
25994 {
25995 27 music_stop();
25996 27 playLevelMusic();
25997 27 }
25998
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 else if(get_bit(quest_rules,qr_SCREEN80_OWN_MUSIC))
25999 {
26000 playLevelMusic();
26001 }
26002
26003 325 loadside=dir^1;
26004 325 }
26005
26006 12639 bool HeroClass::nextcombo_wf(int32_t d2)
26007 {
26008
6/8
✓ Branch 0 taken 12588 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 12342 times.
✓ Branch 3 taken 246 times.
✓ Branch 4 taken 12342 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 246 times.
✗ Branch 7 not taken.
12639 if(toogam || (action!=swimming && !IsSideSwim() && action != swimhit) || hopclk==0) //!DIMITODO: ...does swimming just let you ignore smart scrolling entirely!?
26009 12639 return false;
26010
26011 // assumes Hero is about to scroll screens
26012
26013 int32_t ns = nextscr(d2);
26014
26015 if(ns==0xFFFF)
26016 return false;
26017
26018 // want actual screen index, not game->maps[] index
26019 ns = (ns&127) + (ns>>7)*MAPSCRS;
26020
26021 int32_t cx = x;
26022 int32_t cy = y;
26023
26024 switch(d2)
26025 {
26026 case up:
26027 cy=160;
26028 break;
26029
26030 case down:
26031 cy=0;
26032 break;
26033
26034 case left:
26035 cx=240;
26036 break;
26037
26038 case right:
26039 cx=0;
26040 break;
26041 }
26042
26043 // check lower half of combo
26044 cy += 8;
26045
26046 // from MAPCOMBO()
26047 int32_t cmb = (cy&0xF0)+(cx>>4);
26048
26049 if(cmb>175)
26050 return true;
26051
26052 newcombo c = combobuf[TheMaps[ns].data[cmb]];
26053 bool dried = iswater_type(c.type) && DRIEDLAKE;
26054 bool swim = iswater_type(c.type) && (current_item(itype_flippers)) && !dried;
26055 int32_t b=1;
26056
26057 if(cx&8) b<<=2;
26058
26059 if(cy&8) b<<=1;
26060
26061 if((c.walk&b) && !dried && !swim)
26062 return true;
26063
26064 // next block (i.e. cnt==2)
26065 if(!(cx&8))
26066 {
26067 b<<=2;
26068 }
26069 else
26070 {
26071 c = combobuf[TheMaps[ns].data[++cmb]];
26072 dried = iswater_type(c.type) && DRIEDLAKE;
26073 swim = iswater_type(c.type) && (current_item(itype_flippers)) && !dried;
26074 b=1;
26075
26076 if(cy&8)
26077 {
26078 b<<=1;
26079 }
26080 }
26081
26082 return (c.walk&b) ? !dried && !swim : false;
26083 12639 }
26084
26085 bool HeroClass::nextcombo_solid(int32_t d2)
26086 {
26087 if(toogam || currscr>=128)
26088 return false;
26089
26090 // assumes Hero is about to scroll screens
26091
26092 int32_t ns = nextscr(d2);
26093
26094 if(ns==0xFFFF)
26095 return false;
26096
26097 // want actual screen index, not game->maps[] index
26098 ns = (ns&127) + (ns>>7)*MAPSCRS;
26099 int32_t screen = (ns%MAPSCRS);
26100 int32_t map = (ns - screen) / MAPSCRS;
26101
26102 int32_t cx = x;
26103 int32_t cy = y;
26104
26105 switch(d2)
26106 {
26107 case up:
26108 cy=160;
26109 break;
26110
26111 case down:
26112 cy=0;
26113 break;
26114
26115 case left:
26116 cx=240;
26117 break;
26118
26119 case right:
26120 cx=0;
26121 break;
26122 }
26123
26124 if(d2==up) cy += 8;
26125
26126 if(d2==left||d2==right) cy+=bigHitbox?0:8;
26127
26128 int32_t initcx = cx;
26129 int32_t initcy = cy;
26130 // from MAPCOMBO()
26131
26132 for(int32_t i=0; i<=((bigHitbox&&!(d2==up||d2==down))?((initcy&7)?2:1):((initcy&7)?1:0)) && cy < 176; cy+=(cy%2)?7:8,i++)
26133 {
26134 cx = initcx;
26135 for(int32_t k=0; k<=(get_bit(quest_rules, qr_SMARTER_SMART_SCROLL)?((initcx&7)?2:1):0) && cx < 256; cx+=(cx%2)?7:8,k++)
26136 {
26137 int32_t cmb = (cy&0xF0)+(cx>>4);
26138
26139 if(cmb>175)
26140 {
26141 return true;
26142 }
26143
26144 newcombo const& c = combobuf[MAPCOMBO3(map, screen, -1,cx,cy, get_bit(quest_rules, qr_SMARTER_SMART_SCROLL))];
26145
26146 int32_t b=1;
26147
26148 if(cx&8) b<<=2;
26149
26150 if(cy&8) b<<=1;
26151
26152 //bool bridgedetected = false;
26153
26154 int32_t walk = c.walk;
26155 if (get_bit(quest_rules, qr_SMARTER_SMART_SCROLL))
26156 {
26157 for (int32_t m = 0; m <= 1; m++)
26158 {
26159 newcombo const& cmb = combobuf[MAPCOMBO3(map, screen, m,cx,cy, true)];
26160 if (cmb.type == cBRIDGE)
26161 {
26162 if (!get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
26163 {
26164 int efflag = (cmb.walk & 0xF0)>>4;
26165 int newsolid = (cmb.walk & 0xF);
26166 walk = ((newsolid | walk) & (~efflag)) | (newsolid & efflag);
26167 }
26168 else walk &= cmb.walk;
26169 }
26170 else walk |= cmb.walk;
26171 }
26172 }
26173 /*
26174 if (bridgedetected)
26175 {
26176 continue;
26177 }*/
26178
26179 //bool swim = iswater_type(c.type) && (current_item(itype_flippers) || action==rafting);
26180 bool swim = iswaterex(MAPCOMBO3(map, screen, -1,cx,cy, get_bit(quest_rules, qr_SMARTER_SMART_SCROLL)), map, screen, -1, cx, cy, true, false, true) && (current_item(itype_flippers) || action==rafting);
26181
26182 if((walk&b) && !swim)
26183 {
26184 return true;
26185 }
26186 }
26187
26188 /*
26189 #if 0
26190
26191 //
26192 // next block (i.e. cnt==2)
26193 if(!(cx&8))
26194 {
26195 b<<=2;
26196 }
26197 else
26198 {
26199 c = combobuf[TheMaps[ns].data[++cmb]];
26200 dried = iswater_type(c.type) && DRIEDLAKE;
26201 //swim = iswater_type(c.type) && (current_item(itype_flippers));
26202 b=1;
26203
26204 if(cy&8)
26205 {
26206 b<<=1;
26207 }
26208 }
26209
26210 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
26211
26212 if((c.walk&b) && !dried && !swim)
26213 {
26214 return true;
26215 }
26216
26217 cx+=8;
26218
26219 if(cx&7)
26220 {
26221 if(!(cx&8))
26222 {
26223 b<<=2;
26224 }
26225 else
26226 {
26227 c = combobuf[TheMaps[ns].data[++cmb]];
26228 dried = iswater_type(c.type) && DRIEDLAKE;
26229 //swim = iswaterex(cmb, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
26230 b=1;
26231
26232 if(cy&8)
26233 {
26234 b<<=1;
26235 }
26236 }
26237
26238 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
26239
26240 if((c.walk&b) && !dried && !swim)
26241 return true;
26242 }
26243
26244 #endif
26245 */
26246 }
26247
26248 return false;
26249 }
26250
26251 6419576 void HeroClass::checkscroll()
26252 {
26253 //DO NOT scroll if Hero is vibrating due to Divine Escape effect -DD
26254
2/4
✓ Branch 0 taken 6419576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6419576 times.
✗ Branch 3 not taken.
6419576 if(action == casting||action==sideswimcasting)
26255 return;
26256
26257
2/2
✓ Branch 0 taken 6406170 times.
✓ Branch 1 taken 13406 times.
6419576 if(toogam)
26258 {
26259
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 13398 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
13406 if(x<0 && (currscr&15)==0) x=0;
26260
26261
3/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 13386 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
13406 if(y<0 && currscr<16) y=0;
26262
26263
3/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 13391 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
13406 if(x>240 && (currscr&15)==15) x=240;
26264
26265
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 13398 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
13406 if(y>160 && currscr>=112) y=160;
26266 13406 }
26267
26268
2/2
✓ Branch 0 taken 6416186 times.
✓ Branch 1 taken 3390 times.
6419576 if(y<0)
26269 {
26270 3390 bool doit=true;
26271 3390 y=0;
26272
26273
4/6
✓ Branch 0 taken 3389 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3389 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3388 times.
3390 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
26274 doit = false;
26275
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3388 if(lift_wpn && get_bit(quest_rules,qr_NO_SCROLL_WHILE_CARRYING))
26276 doit = false;
26277
26278
1/2
✓ Branch 0 taken 3388 times.
✗ Branch 1 not taken.
3388 if(nextcombo_wf(up))
26279 doit=false;
26280
26281
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 3388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
3388 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling && !(tmpscr->flags2&wfUP))
26282 {
26283 if(nextcombo_solid(up))
26284 doit=false;
26285 }
26286
26287
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3388 if(doit || action==inwind)
26288 {
26289
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 3063 times.
3388 if(currscr>=128)
26290 {
26291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 325 times.
325 if(specialcave >= GUYCAVE)
26292 exitcave();
26293 325 else stepout();
26294 325 }
26295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3063 times.
3063 else if(action==inwind)
26296 {
26297 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
26298 {
26299 action=none; FFCore.setHeroAction(none);
26300 restart_level();
26301 }
26302 else
26303 {
26304 dowarp(2,up);
26305 }
26306 }
26307
3/6
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 2989 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3063 else if(tmpscr->flags2&wfUP && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
26308 {
26309 74 sdir=up;
26310 74 dowarp(1,(tmpscr->sidewarpindex)&3);
26311 74 }
26312
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2981 times.
2989 else if(!edge_of_dmap(up))
26313 {
26314 2981 scrolling_map = currmap;
26315 2981 scrollscr(up);
26316
26317
1/2
✓ Branch 0 taken 2981 times.
✗ Branch 1 not taken.
2981 if(tmpscr->flags4&fAUTOSAVE)
26318 {
26319 save_game(true,0);
26320 }
26321
26322
2/2
✓ Branch 0 taken 2977 times.
✓ Branch 1 taken 4 times.
2981 if(tmpscr->flags6&fCONTINUEHERE)
26323 {
26324 4 lastentrance_dmap = currdmap;
26325 4 lastentrance = homescr;
26326 4 }
26327 2981 }
26328 3388 }
26329 3388 }
26330
26331
2/2
✓ Branch 0 taken 6416975 times.
✓ Branch 1 taken 2599 times.
6419574 if(y>160)
26332 {
26333 2599 bool doit=true;
26334 2599 y=160;
26335
26336
5/6
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 2560 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 40 times.
✓ Branch 5 taken 2559 times.
2599 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
26337 40 doit = false;
26338
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2599 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2599 if(lift_wpn && get_bit(quest_rules,qr_NO_SCROLL_WHILE_CARRYING))
26339 doit = false;
26340
26341
1/2
✓ Branch 0 taken 2599 times.
✗ Branch 1 not taken.
2599 if(nextcombo_wf(down))
26342 doit=false;
26343
26344
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 2599 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2599 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfDOWN))
26345 {
26346 if(nextcombo_solid(down))
26347 doit=false;
26348 }
26349
26350
3/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 2559 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
2599 if(doit || action==inwind)
26351 {
26352
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 2300 times.
2559 if(currscr>=128)
26353 {
26354
1/2
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
259 if(specialcave >= GUYCAVE)
26355 259 exitcave();
26356 else stepout();
26357 259 }
26358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2300 times.
2300 else if(action==inwind)
26359 {
26360 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
26361 {
26362 action=none; FFCore.setHeroAction(none);
26363 restart_level();
26364 }
26365 else
26366 {
26367 dowarp(2,down);
26368 }
26369 }
26370
3/6
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 2125 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 175 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2300 else if(tmpscr->flags2&wfDOWN && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
26371 {
26372 175 sdir=down;
26373 175 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
26374 175 }
26375
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2120 times.
2125 else if(!edge_of_dmap(down))
26376 {
26377 2120 scrolling_map = currmap;
26378 2120 scrollscr(down);
26379
26380
1/2
✓ Branch 0 taken 2120 times.
✗ Branch 1 not taken.
2120 if(tmpscr->flags4&fAUTOSAVE)
26381 {
26382 save_game(true,0);
26383 }
26384
26385
2/2
✓ Branch 0 taken 2118 times.
✓ Branch 1 taken 2 times.
2120 if(tmpscr->flags6&fCONTINUEHERE)
26386 {
26387 2 lastentrance_dmap = currdmap;
26388 2 lastentrance = homescr;
26389 2 }
26390 2120 }
26391 2559 }
26392 2599 }
26393
26394
2/2
✓ Branch 0 taken 6416932 times.
✓ Branch 1 taken 2642 times.
6419574 if(x<0)
26395 {
26396 2642 bool doit=true;
26397 2642 x=0;
26398
26399
5/6
✓ Branch 0 taken 2634 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2634 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 2632 times.
2642 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
26400 8 doit = false;
26401
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2639 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2640 if(lift_wpn && get_bit(quest_rules,qr_NO_SCROLL_WHILE_CARRYING))
26402 doit = false;
26403
26404
1/2
✓ Branch 0 taken 2640 times.
✗ Branch 1 not taken.
2640 if(nextcombo_wf(left))
26405 doit=false;
26406
26407
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 2640 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2640 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfLEFT))
26408 {
26409 if(nextcombo_solid(left))
26410 doit=false;
26411 }
26412
26413
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2632 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 9 times.
2640 if(doit || action==inwind)
26414 {
26415
1/2
✓ Branch 0 taken 2633 times.
✗ Branch 1 not taken.
2633 if(currscr>=128)
26416 {
26417 if(specialcave >= GUYCAVE)
26418 exitcave();
26419 else stepout();
26420 }
26421
26422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2633 times.
2633 if(action==inwind)
26423 {
26424 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
26425 {
26426 action=none; FFCore.setHeroAction(none);
26427 restart_level();
26428 }
26429 else
26430 {
26431 dowarp(2,left);
26432 }
26433 }
26434
3/6
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 2540 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2633 else if(tmpscr->flags2&wfLEFT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
26435 {
26436 93 sdir=left;
26437 93 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
26438 93 }
26439
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 2451 times.
2540 else if(!edge_of_dmap(left))
26440 {
26441 2451 scrolling_map = currmap;
26442 2451 scrollscr(left);
26443
26444
1/2
✓ Branch 0 taken 2451 times.
✗ Branch 1 not taken.
2451 if(tmpscr->flags4&fAUTOSAVE)
26445 {
26446 save_game(true,0);
26447 }
26448
26449
2/2
✓ Branch 0 taken 2443 times.
✓ Branch 1 taken 8 times.
2451 if(tmpscr->flags6&fCONTINUEHERE)
26450 {
26451 8 lastentrance_dmap = currdmap;
26452 8 lastentrance = homescr;
26453 8 }
26454 2451 }
26455 2633 }
26456 2642 }
26457
26458
2/2
✓ Branch 0 taken 6416527 times.
✓ Branch 1 taken 3045 times.
6419572 if(x>240)
26459 {
26460 3045 bool doit=true;
26461 3045 x=240;
26462
26463
3/6
✓ Branch 0 taken 3045 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3045 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3045 times.
3045 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
26464 doit = false;
26465
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3045 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3045 if(lift_wpn && get_bit(quest_rules,qr_NO_SCROLL_WHILE_CARRYING))
26466 doit = false;
26467
26468
1/2
✓ Branch 0 taken 3045 times.
✗ Branch 1 not taken.
3045 if(nextcombo_wf(right))
26469 doit=false;
26470
26471
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 3045 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
3045 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfRIGHT))
26472 {
26473 if(nextcombo_solid(right))
26474 doit=false;
26475 }
26476
26477
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3045 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3045 if(doit || action==inwind)
26478 {
26479
1/2
✓ Branch 0 taken 3045 times.
✗ Branch 1 not taken.
3045 if(currscr>=128)
26480 {
26481 if(specialcave >= GUYCAVE)
26482 exitcave();
26483 else stepout();
26484 }
26485
26486
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 2978 times.
3045 if(action==inwind)
26487 {
26488
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 66 times.
67 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
26489 {
26490 1 action=none; FFCore.setHeroAction(none);
26491 1 restart_level();
26492 1 }
26493 else
26494 {
26495 66 dowarp(2,right);
26496 }
26497 67 }
26498
3/6
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2876 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2978 else if(tmpscr->flags2&wfRIGHT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
26499 {
26500 102 sdir=right;
26501 102 dowarp(1,(tmpscr->sidewarpindex>>6)&3);
26502 102 }
26503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2876 times.
2876 else if(!edge_of_dmap(right))
26504 {
26505 2876 scrolling_map = currmap;
26506 2876 scrollscr(right);
26507
26508
1/2
✓ Branch 0 taken 2876 times.
✗ Branch 1 not taken.
2876 if(tmpscr->flags4&fAUTOSAVE)
26509 {
26510 save_game(true,0);
26511 }
26512
26513
2/2
✓ Branch 0 taken 2866 times.
✓ Branch 1 taken 10 times.
2876 if(tmpscr->flags6&fCONTINUEHERE)
26514 {
26515 10 lastentrance_dmap = currdmap;
26516 10 lastentrance = homescr;
26517 10 }
26518 2876 }
26519 3045 }
26520 3045 }
26521 6419572 }
26522
26523 // assumes current direction is in lastdir[3]
26524 // compares directions with scr->path and scr->exitdir
26525 31281 bool HeroClass::checkmaze(mapscr *scr, bool sound)
26526 {
26527
2/2
✓ Branch 0 taken 30930 times.
✓ Branch 1 taken 351 times.
31281 if(!(scr->flags&fMAZE))
26528 30930 return true;
26529
26530
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 305 times.
351 if(lastdir[3]==scr->exitdir)
26531 46 return true;
26532
26533
2/2
✓ Branch 0 taken 479 times.
✓ Branch 1 taken 44 times.
523 for(int32_t i=0; i<4; i++)
26534
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 261 times.
479 if(lastdir[i]!=scr->path[i])
26535 261 return false;
26536
26537
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 22 times.
44 if(sound)
26538 22 sfx(scr->secretsfx);
26539
26540 44 return true;
26541 31281 }
26542
26543 20852 bool HeroClass::edge_of_dmap(int32_t side)
26544 {
26545
2/2
✓ Branch 0 taken 20699 times.
✓ Branch 1 taken 153 times.
20852 if(checkmaze(tmpscr,false)==false)
26546 153 return false;
26547
26548 // needs fixin'
26549 // should check dmap style
26550
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5877 times.
✓ Branch 2 taken 4197 times.
✓ Branch 3 taken 4934 times.
✓ Branch 4 taken 5691 times.
20699 switch(side)
26551 {
26552 case up:
26553 5877 return currscr<16;
26554
26555 case down:
26556 4197 return currscr>=112;
26557
26558 case left:
26559
2/2
✓ Branch 0 taken 4845 times.
✓ Branch 1 taken 89 times.
4934 if((currscr&15)==0)
26560 89 return true;
26561
26562
2/2
✓ Branch 0 taken 2574 times.
✓ Branch 1 taken 2271 times.
4845 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
26563 // if(dlevel)
26564 2574 return (((currscr&15)-DMaps[currdmap].xoff)<=0);
26565
26566 2271 break;
26567
26568 case right:
26569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5691 times.
5691 if((currscr&15)==15)
26570 return true;
26571
26572
2/2
✓ Branch 0 taken 3205 times.
✓ Branch 1 taken 2486 times.
5691 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
26573 // if(dlevel)
26574 3205 return (((currscr&15)-DMaps[currdmap].xoff)>=7);
26575
26576 2486 break;
26577 }
26578
26579 4757 return false;
26580 20852 }
26581
26582 196 bool HeroClass::lookaheadraftflag(int32_t d2)
26583 {
26584 // Helper for scrollscr that gets next combo on next screen.
26585 // Can use destscr for scrolling warps,
26586 // but assumes currmap is correct.
26587
26588 196 int32_t cx = x;
26589 196 int32_t cy = y + 8;
26590
26591 196 bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26592 196 bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26593 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
26594 //Applying this here, too. -Z
26595
26596
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 41 times.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 57 times.
196 switch(d2)
26597 {
26598 case up:
26599 51 cy=160;
26600 51 break;
26601
26602 case down:
26603 41 cy=0;
26604 41 break;
26605
26606 case left:
26607 47 cx=240;
26608 47 break;
26609
26610 case right:
26611 57 cx=0;
26612 57 break;
26613 }
26614
26615 196 int32_t combo = (cy&0xF0)+(cx>>4);
26616
26617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 if(combo>175)
26618 return 0;
26619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 return ( isRaftFlag(combobuf[tmpscr[0].data[combo]].flag) || isRaftFlag(tmpscr[0].sflag[combo]));
26620
26621 196 }
26622 10743 int32_t HeroClass::lookahead(int32_t d2) // Helper for scrollscr that gets next combo on next screen.
26623 {
26624 // Can use destscr for scrolling warps,
26625 // but assumes currmap is correct.
26626
26627 10743 int32_t cx = vbound(x,0,240); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
26628 10743 int32_t cy = vbound(y + 8,0,160);
26629 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26630 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26631 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
26632
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3027 times.
✓ Branch 2 taken 2174 times.
✓ Branch 3 taken 2518 times.
✓ Branch 4 taken 3024 times.
10743 switch(d2)
26633 {
26634 case up:
26635 3027 cy=160;
26636 3027 break;
26637
26638 case down:
26639 2174 cy=0;
26640 2174 break;
26641
26642 case left:
26643 2518 cx=240;
26644 2518 break;
26645
26646 case right:
26647 3024 cx=0;
26648 3024 break;
26649 }
26650
26651 10743 int32_t combo = (cy&0xF0)+(cx>>4);
26652
26653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10743 times.
10743 if(combo>175)
26654 return 0;
26655
26656 10743 return tmpscr[0].data[combo]; // entire combo code
26657 10743 }
26658
26659 10743 int32_t HeroClass::lookaheadflag(int32_t d2)
26660 {
26661 // Helper for scrollscr that gets next combo on next screen.
26662 // Can use destscr for scrolling warps,
26663 // but assumes currmap is correct.
26664
26665 10743 int32_t cx = vbound(x,0,240);
26666 10743 int32_t cy = vbound(y + 8,0,160);
26667
26668 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26669 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26670 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
26671 //Applying this here, too. -Z
26672
26673
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3027 times.
✓ Branch 2 taken 2174 times.
✓ Branch 3 taken 2518 times.
✓ Branch 4 taken 3024 times.
10743 switch(d2)
26674 {
26675 case up:
26676 3027 cy=160;
26677 3027 break;
26678
26679 case down:
26680 2174 cy=0;
26681 2174 break;
26682
26683 case left:
26684 2518 cx=240;
26685 2518 break;
26686
26687 case right:
26688 3024 cx=0;
26689 3024 break;
26690 }
26691
26692 10743 int32_t combo = (cy&0xF0)+(cx>>4);
26693
26694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10743 times.
10743 if(combo>175)
26695 return 0;
26696
26697
2/2
✓ Branch 0 taken 10464 times.
✓ Branch 1 taken 279 times.
10743 if(!tmpscr[0].sflag[combo])
26698 {
26699 10464 return combobuf[tmpscr[0].data[combo]].flag; // flag
26700 }
26701
26702 279 return tmpscr[0].sflag[combo]; // flag
26703 10743 }
26704
26705 //Bit of a messy kludge to give the correct Hero->X/Hero->Y in the script
26706 1397763 void HeroClass::run_scrolling_script(int32_t scrolldir, int32_t cx, int32_t sx, int32_t sy, bool end_frames, bool waitdraw)
26707 {
26708 // For rafting (and possibly other esoteric things)
26709 // Hero's action should remain unchanged while scrolling,
26710 // but for the sake of scripts, here's an eye-watering kludge.
26711 1397763 actiontype lastaction = action;
26712 1397763 action=scrolling; FFCore.setHeroAction(scrolling);
26713
2/2
✓ Branch 0 taken 698761 times.
✓ Branch 1 taken 699002 times.
1397763 if(waitdraw)
26714 {
26715 698761 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
26716 698761 }
26717 else
26718 {
26719 699002 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS-1);
26720 }
26721 1397763 zfix storex = x, storey = y;
26722
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 348497 times.
✓ Branch 2 taken 237357 times.
✓ Branch 3 taken 367618 times.
✓ Branch 4 taken 444291 times.
1397763 switch(scrolldir)
26723 {
26724 case up:
26725
2/2
✓ Branch 0 taken 290295 times.
✓ Branch 1 taken 58202 times.
348497 if(y < 160) y = 176;
26726
4/4
✓ Branch 0 taken 49381 times.
✓ Branch 1 taken 8821 times.
✓ Branch 2 taken 18900 times.
✓ Branch 3 taken 30481 times.
58202 else if(cx > 0 && !end_frames) y = sy + 156;
26727 27721 else y = 160;
26728
26729 348497 break;
26730
26731 case down:
26732
2/2
✓ Branch 0 taken 196824 times.
✓ Branch 1 taken 40533 times.
237357 if(y > 0) y = -16;
26733
4/4
✓ Branch 0 taken 34123 times.
✓ Branch 1 taken 6410 times.
✓ Branch 2 taken 14133 times.
✓ Branch 3 taken 19990 times.
40533 else if(cx > 0 && !end_frames) y = sy - 172;
26734 20543 else y = 0;
26735
26736 237357 break;
26737
26738 case left:
26739
2/2
✓ Branch 0 taken 337768 times.
✓ Branch 1 taken 29850 times.
367618 if(x < 240) x = 256;
26740
2/2
✓ Branch 0 taken 24758 times.
✓ Branch 1 taken 5092 times.
29850 else if(cx > 0) x = sx + 236;
26741 5092 else x = 240;
26742
26743 367618 break;
26744
26745 case right:
26746
2/2
✓ Branch 0 taken 408267 times.
✓ Branch 1 taken 36024 times.
444291 if(x > 0) x = -16;
26747
2/2
✓ Branch 0 taken 29902 times.
✓ Branch 1 taken 6122 times.
36024 else if(cx > 0) x = sx - 252;
26748 6122 else x = 0;
26749
26750 444291 break;
26751 }
26752
2/2
✓ Branch 0 taken 698761 times.
✓ Branch 1 taken 699002 times.
1397763 if(waitdraw)
26753 {
26754
3/4
✓ Branch 0 taken 698761 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 602383 times.
✓ Branch 3 taken 96378 times.
698761 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (global_wait & (1<<GLOBAL_SCRIPT_GAME)))
26755 {
26756 96378 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
26757 96378 global_wait&= ~(1<<GLOBAL_SCRIPT_GAME);
26758 96378 }
26759 698761 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
26760
4/6
✓ Branch 0 taken 698761 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3407 times.
✓ Branch 3 taken 695354 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3407 times.
698761 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && player_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26761 {
26762 3407 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
26763 3407 player_waitdraw = false;
26764 3407 }
26765 698761 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
26766
4/6
✓ Branch 0 taken 698761 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 698727 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 34 times.
698761 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26767 {
26768 34 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
26769 34 dmap_waitdraw = false;
26770 34 }
26771 698761 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
26772
2/6
✓ Branch 0 taken 698761 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 698761 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
698761 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26773 {
26774 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
26775 passive_subscreen_waitdraw = false;
26776 }
26777 698761 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
26778
4/10
✓ Branch 0 taken 698761 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 698744 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
698761 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->screen_waitdraw && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26779 {
26780 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
26781 tmpscr->screen_waitdraw = 0;
26782 }
26783 698761 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
26784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 698761 times.
698761 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
26785 {
26786 698761 FFCore.itemScriptEngineOnWaitdraw();
26787 698761 }
26788 698761 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
26789 698761 }
26790 else
26791 {
26792
4/8
✓ Branch 0 taken 699002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 698984 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
699002 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26793 {
26794 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
26795 }
26796 699002 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS);
26797
3/4
✓ Branch 0 taken 699002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549315 times.
✓ Branch 3 taken 149687 times.
699002 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (g_doscript & (1<<GLOBAL_SCRIPT_GAME)))
26798 {
26799 149687 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
26800 149687 }
26801 699002 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_ACTIVE);
26802
5/6
✓ Branch 0 taken 699002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 689963 times.
✓ Branch 3 taken 9039 times.
✓ Branch 4 taken 686556 times.
✓ Branch 5 taken 3407 times.
699002 if ((!( FFCore.system_suspend[susptHEROACTIVE] )) && player_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255)
26803 {
26804 3407 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
26805 3407 }
26806 699002 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_ACTIVE);
26807
4/6
✓ Branch 0 taken 699002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 699002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 686556 times.
✓ Branch 5 taken 12446 times.
699002 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26808 {
26809 12446 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
26810 12446 }
26811 699002 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE);
26812
4/6
✓ Branch 0 taken 699002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 699002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 686556 times.
✓ Branch 5 taken 12446 times.
699002 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26813 {
26814 12446 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
26815 12446 }
26816 699002 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN);
26817 699002 bool old = get_bit(quest_rules, qr_OLD_ITEMDATA_SCRIPT_TIMING);
26818
3/4
✓ Branch 0 taken 699002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6264 times.
✓ Branch 3 taken 692738 times.
699002 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && old)
26819 692738 FFCore.itemScriptEngine();
26820 699002 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_OLD_ITEMDATA_SCRIPT);
26821
3/4
✓ Branch 0 taken 699002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 692738 times.
✓ Branch 3 taken 6264 times.
699002 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && !old)
26822 6264 FFCore.itemScriptEngine();
26823 }
26824
26825 1397763 x = storex, y = storey;
26826
26827 1397763 action=lastaction; FFCore.setHeroAction(lastaction);
26828 1397763 }
26829
26830 //Has solving the maze enabled a side warp?
26831 //Only used just before scrolling screens
26832 // Note: since scrollscr() calls this, and dowarp() calls scrollscr(),
26833 // return true to abort the topmost scrollscr() call. -L
26834 10744 bool HeroClass::maze_enabled_sizewarp(int32_t scrolldir)
26835 {
26836
2/2
✓ Branch 0 taken 32232 times.
✓ Branch 1 taken 10744 times.
42976 for(int32_t i = 0; i < 3; i++) lastdir[i] = lastdir[i+1];
26837
26838
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 10591 times.
10744 lastdir[3] = tmpscr->flags&fMAZE ? scrolldir : 0xFF;
26839
26840
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10744 if(tmpscr->flags8&fMAZEvSIDEWARP && tmpscr->flags&fMAZE && scrolldir != tmpscr->exitdir)
26841 {
26842 switch(scrolldir)
26843 {
26844 case up:
26845 if(tmpscr->flags2&wfUP && checkmaze(tmpscr,true))
26846 {
26847 lastdir[3] = 0xFF;
26848 sdir=up;
26849 dowarp(1,(tmpscr->sidewarpindex)&3);
26850 return true;
26851 }
26852
26853 break;
26854
26855 case down:
26856 if(tmpscr->flags2&wfDOWN && checkmaze(tmpscr,true))
26857 {
26858 lastdir[3] = 0xFF;
26859 sdir=down;
26860 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
26861 return true;
26862 }
26863
26864 break;
26865
26866 case left:
26867 if(tmpscr->flags2&wfLEFT && checkmaze(tmpscr,true))
26868 {
26869 lastdir[3] = 0xFF;
26870 sdir=left;
26871 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
26872 return true;
26873 }
26874
26875 break;
26876
26877 case right:
26878 if(tmpscr->flags2&wfRIGHT && checkmaze(tmpscr,true))
26879 {
26880 lastdir[3] = 0xFF;
26881 sdir=right;
26882 dowarp(1,(tmpscr->sidewarpindex)&3);
26883 return true;
26884 }
26885
26886 break;
26887 }
26888 }
26889
26890 10744 return false;
26891 10744 }
26892
26893 10744 int32_t HeroClass::get_scroll_step(int32_t scrolldir)
26894 {
26895 // For side-scrollers, where the relative speed of 'fast' scrolling is a bit slow.
26896
2/2
✓ Branch 0 taken 636 times.
✓ Branch 1 taken 10108 times.
10744 if(get_bit(quest_rules, qr_VERYFASTSCROLLING))
26897 636 return 16;
26898
26899
2/2
✓ Branch 0 taken 9079 times.
✓ Branch 1 taken 1029 times.
10108 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) != 0)
26900 {
26901
2/2
✓ Branch 0 taken 5121 times.
✓ Branch 1 taken 3958 times.
9079 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 2 : 4;
26902 }
26903 else
26904 {
26905
4/4
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 155 times.
✓ Branch 3 taken 547 times.
1029 if(scrolldir == up || scrolldir == down)
26906 {
26907 482 return 8;
26908 }
26909 else
26910 {
26911
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 332 times.
547 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 2 : 4;
26912 }
26913 }
26914 10744 }
26915
26916 10744 int32_t HeroClass::get_scroll_delay(int32_t scrolldir)
26917 {
26918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10744 times.
10744 if(get_bit(quest_rules, qr_NOSCROLL))
26919 return 0;
26920
26921
4/4
✓ Branch 0 taken 10108 times.
✓ Branch 1 taken 636 times.
✓ Branch 2 taken 9079 times.
✓ Branch 3 taken 1029 times.
10744 if( (get_bit(quest_rules, qr_VERYFASTSCROLLING) != 0) ||
26922 10108 (get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) != 0) )
26923 {
26924 9715 return 1;
26925 }
26926 else
26927 {
26928
4/4
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 155 times.
✓ Branch 3 taken 547 times.
1029 if(scrolldir == up || scrolldir == down)
26929 {
26930
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 234 times.
482 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 4 : 2;
26931 }
26932 else
26933 {
26934 547 return 1;
26935 }
26936 }
26937 10744 }
26938
26939 5933 void HeroClass::calc_darkroom_hero(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
26940 {
26941 5933 int32_t lampid = current_item_id(itype_lantern);
26942
1/2
✓ Branch 0 taken 5933 times.
✗ Branch 1 not taken.
5933 if(lampid < 0) return;
26943 static bool lamp_paid = false;
26944
2/4
✓ Branch 0 taken 5933 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5933 times.
✗ Branch 3 not taken.
5933 if(!(checkbunny(lampid) && checkmagiccost(lampid,lamp_paid)))
26945 {
26946 lamp_paid = false;
26947 return;
26948 }
26949 5933 lamp_paid = true;
26950 5933 paymagiccost(lampid,false,true);
26951 5933 int32_t hx1 = x.getInt() - x1 + 8;
26952 5933 int32_t hy1 = y.getInt() - y1 + 8;
26953 5933 int32_t hx2 = x.getInt() - x2 + 8;
26954 5933 int32_t hy2 = y.getInt() - y2 + 8;
26955
26956 5933 itemdata& lamp = itemsbuf[lampid];
26957
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5545 times.
✓ Branch 2 taken 388 times.
5933 switch(lamp.misc1) //Shape
26958 {
26959 case 0: //Circle
26960 5545 doDarkroomCircle(hx1, hy1, lamp.misc2, darkscr_bmp_curscr);
26961 5545 doDarkroomCircle(hx2, hy2, lamp.misc2, darkscr_bmp_scrollscr);
26962 5545 break;
26963 case 1: //Lamp Cone
26964 388 doDarkroomCone(hx1, hy1, lamp.misc2, dir, darkscr_bmp_curscr);
26965 388 doDarkroomCone(hx2, hy2, lamp.misc2, dir, darkscr_bmp_scrollscr);
26966 388 break;
26967 }
26968 5933 }
26969
26970 10745 void HeroClass::scrollscr(int32_t scrolldir, int32_t destscr, int32_t destdmap)
26971 {
26972
4/4
✓ Branch 0 taken 10744 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 10745 times.
10745 if(action==freeze||action==sideswimfreeze)
26973 {
26974 2 return;
26975 }
26976
26977 10745 bool overlay = false;
26978
26979
3/4
✓ Branch 0 taken 10744 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10744 times.
10745 if(scrolldir >= 0 && scrolldir <= 3)
26980 {
26981 10744 overlay = get_bit(&tmpscr[(currscr < 128) ? 0 : 1].sidewarpoverlayflags, scrolldir) ? true : false;
26982 10744 }
26983
26984
2/2
✓ Branch 0 taken 316 times.
✓ Branch 1 taken 10429 times.
10745 if(destdmap == -1)
26985 {
26986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10429 times.
10429 if(ZCMaps[currmap].tileWidth != ZCMaps[DMaps[currdmap].map].tileWidth
26987
1/2
✓ Branch 0 taken 10429 times.
✗ Branch 1 not taken.
10429 || ZCMaps[currmap].tileHeight != ZCMaps[DMaps[currdmap].map].tileHeight)
26988 return;
26989 10429 }
26990 else
26991 {
26992
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 316 times.
316 if(ZCMaps[currmap].tileWidth != ZCMaps[DMaps[destdmap].map].tileWidth
26993
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 1 times.
316 || ZCMaps[currmap].tileHeight != ZCMaps[DMaps[destdmap].map].tileHeight)
26994 2 return;
26995 }
26996
26997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10745 times.
10745 if(maze_enabled_sizewarp(scrolldir)) // dowarp() was called
26998 return;
26999
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10745 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10745 bool isForceFaceUp = getOnSideviewLadder() && canSideviewLadder() &&
27000 !(jumping<0 || fall!=0 || fakefall!=0) && get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP);
27001
1/2
✓ Branch 0 taken 10745 times.
✗ Branch 1 not taken.
10745 if(isForceFaceUp) dir = up;
27002 10745 kill_enemy_sfx();
27003 10745 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
27004 10745 screenscrolling = true;
27005 10745 FFCore.ScrollingData[SCROLLDATA_DIR] = scrolldir;
27006
5/5
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3028 times.
✓ Branch 2 taken 2174 times.
✓ Branch 3 taken 2518 times.
✓ Branch 4 taken 3024 times.
10745 switch(scrolldir)
27007 {
27008 case up:
27009 3028 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
27010 3028 FFCore.ScrollingData[SCROLLDATA_NY] = -176;
27011 3028 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27012 3028 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27013 3028 break;
27014 case down:
27015 2174 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
27016 2174 FFCore.ScrollingData[SCROLLDATA_NY] = 176;
27017 2174 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27018 2174 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27019 2174 break;
27020 case left:
27021 2518 FFCore.ScrollingData[SCROLLDATA_NX] = -256;
27022 2518 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
27023 2518 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27024 2518 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27025 2518 break;
27026 case right:
27027 3024 FFCore.ScrollingData[SCROLLDATA_NX] = 256;
27028 3024 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
27029 3024 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27030 3024 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27031 3024 break;
27032 }
27033 10745 FFCore.init_combo_doscript();
27034 10745 tmpscr[1] = tmpscr[0];
27035
27036 10745 const int32_t _mapsSize = ZCMaps[currmap].tileWidth * ZCMaps[currmap].tileHeight;
27037
27038
2/2
✓ Branch 0 taken 64464 times.
✓ Branch 1 taken 10745 times.
75209 for(int32_t i = 0; i < 6; i++)
27039 {
27040 64464 tmpscr3[i] = tmpscr2[i];
27041 64464 }
27042
27043 10745 conveyclk = 2;
27044
27045 10745 mapscr *newscr = &tmpscr[0];
27046 10745 mapscr *oldscr = &tmpscr[1];
27047
27048 //scroll x, scroll y, old screen x, old screen y, new screen x, new screen y
27049 10745 int32_t sx = 0, sy = 0, tx = 0, ty = 0, tx2 = 0, ty2 = 0;
27050 10745 int32_t cx = 0;
27051 10745 int32_t step = get_scroll_step(scrolldir);
27052 10745 int32_t delay = get_scroll_delay(scrolldir);
27053 10745 bool end_frames = false;
27054
27055 10745 int32_t scx = get_bit(quest_rules,qr_FASTDNGN) ? 30 : 0;
27056
2/2
✓ Branch 0 taken 10109 times.
✓ Branch 1 taken 636 times.
10745 if(get_bit(quest_rules, qr_VERYFASTSCROLLING)) //just a minor adjustment.
27057 636 scx = 32; //for sideview very fast screolling.
27058
27059
27060 10745 int32_t lastattackclk = attackclk, lastspins = spins, lastcharging = charging; bool lasttapping = tapping;
27061 10745 actiontype lastaction = action;
27062 10745 ALLOFF(false, false);
27063 // for now, restore Hero's previous action
27064
2/2
✓ Branch 0 taken 10504 times.
✓ Branch 1 taken 241 times.
10745 if(!get_bit(quest_rules, qr_SCROLLING_KILLS_CHARGE))
27065 10745 attackclk = lastattackclk; spins = lastspins; charging = lastcharging; tapping = lasttapping;
27066 10745 action=lastaction; FFCore.setHeroAction(lastaction);
27067
27068 10745 lstep = (lstep + 6) % 12;
27069 10745 cx = scx;
27070 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
27071
4/4
✓ Branch 0 taken 10744 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 8649 times.
✓ Branch 3 taken 2095 times.
10745 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (global_wait & (1<<GLOBAL_SCRIPT_GAME)))
27072 {
27073 2095 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
27074 2095 global_wait &= ~(1<<GLOBAL_SCRIPT_GAME);
27075 2095 }
27076 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
27077
5/6
✓ Branch 0 taken 10744 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 194 times.
✓ Branch 3 taken 10550 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 194 times.
10745 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && player_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
27078 {
27079 194 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
27080 194 player_waitdraw = false;
27081 194 }
27082 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
27083
5/6
✓ Branch 0 taken 10744 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 10742 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
10745 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
27084 {
27085 2 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
27086 2 dmap_waitdraw = false;
27087 2 }
27088 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
27089
3/6
✓ Branch 0 taken 10744 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10745 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
27090 {
27091 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
27092 passive_subscreen_waitdraw = false;
27093 }
27094 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
27095
3/8
✓ Branch 0 taken 10744 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
10745 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->screen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
27096 {
27097 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
27098 tmpscr->screen_waitdraw = 0;
27099 }
27100 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
27101
27102 10745 word c = tmpscr->numFFC();
27103
2/2
✓ Branch 0 taken 337747 times.
✓ Branch 1 taken 10745 times.
348492 for ( word q = 0; q < c; ++q )
27104 {
27105 //Z_scripterrlog("tmpscr->ffcswaitdraw is: %d\n", tmpscr->ffcswaitdraw);
27106
1/2
✓ Branch 0 taken 337747 times.
✗ Branch 1 not taken.
337747 if ( tmpscr->ffcswaitdraw&(1<<q) )
27107 {
27108 //Z_scripterrlog("FFC (%d) called Waitdraw()\n", q);
27109 if(tmpscr->ffcs[q].script != 0)
27110 {
27111 ZScriptVersion::RunScript(SCRIPT_FFC, tmpscr->ffcs[q].script, q);
27112 tmpscr->ffcswaitdraw &= ~(1<<q);
27113 }
27114 }
27115 337747 }
27116 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFC_WAITDRAW);
27117 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_COMBO_WAITDRAW);
27118 //Waitdraw for item scripts.
27119 10745 FFCore.itemScriptEngineOnWaitdraw();
27120 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
27121 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_NPC_WAITDRAW);
27122
27123 //Sprite scripts on Waitdraw
27124 10745 FFCore.eweaponScriptEngineOnWaitdraw();
27125 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_EWPN_WAITDRAW);
27126 10745 FFCore.itemSpriteScriptEngineOnWaitdraw();
27127 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEMSPRITE_WAITDRAW);
27128
27129 //This is no longer a do-while, as the first iteration is now slightly different. -Em
27130 10745 draw_screen(tmpscr,true,true);
27131
27132
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10744 times.
10745 if(cx == scx)
27133 10744 rehydratelake(false);
27134
27135 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
27136 10745 advanceframe(true);
27137
27138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10745 times.
10745 if(Quit)
27139 {
27140 screenscrolling = false;
27141 return;
27142 }
27143
27144 10745 ++cx;
27145
2/2
✓ Branch 0 taken 109438 times.
✓ Branch 1 taken 10745 times.
120183 while(cx < 32)
27146 {
27147
1/2
✓ Branch 0 taken 109438 times.
✗ Branch 1 not taken.
109438 if(isForceFaceUp) dir = up;
27148
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 109398 times.
109438 if(get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
27149 {
27150 40 script_drawing_commands.Clear();
27151 40 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
27152 40 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
27153 40 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
27154 40 }
27155 109398 else FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
27156 109438 draw_screen(tmpscr,true,true);
27157
27158
1/2
✓ Branch 0 taken 109438 times.
✗ Branch 1 not taken.
109438 if(cx == scx)
27159 rehydratelake(false);
27160
27161 109438 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
27162 109438 advanceframe(true);
27163
27164
1/2
✓ Branch 0 taken 109438 times.
✗ Branch 1 not taken.
109438 if(Quit)
27165 {
27166 screenscrolling = false;
27167 return;
27168 }
27169
27170 109438 ++cx;
27171 }
27172 10745 script_drawing_commands.Clear();
27173 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
27174
27175
27176 //clear Hero's last hits
27177 //for ( int32_t q = 0; q < 4; q++ ) sethitHeroUID(q, 0);
27178
27179
4/4
✓ Branch 0 taken 5328 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 996 times.
✓ Branch 3 taken 4420 times.
10745 switch(DMaps[currdmap].type&dmfTYPE)
27180 {
27181 case dmDNGN:
27182
1/2
✓ Branch 0 taken 4420 times.
✗ Branch 1 not taken.
4420 if(!get_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING))
27183 {
27184 markBmap(scrolldir);
27185 }
27186 4420 break;
27187 case dmOVERW: case dmBSOVERW:
27188
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 5240 times.
5328 if(get_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING))
27189 5240 break;
27190 [[fallthrough]];
27191 case dmCAVE:
27192 1084 markBmap(scrolldir);
27193 1084 break;
27194 }
27195
27196
1/2
✓ Branch 0 taken 10745 times.
✗ Branch 1 not taken.
10745 if(fixed_door)
27197 {
27198 unsetmapflag(mSECRET);
27199 fixed_door = false;
27200 }
27201 //Z_scripterrlog("Setting 'scrolling_scr' from %d to %d\n", scrolling_scr, currscr);
27202 10745 scrolling_scr = currscr;
27203
27204
5/5
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3028 times.
✓ Branch 2 taken 2174 times.
✓ Branch 3 taken 2518 times.
✓ Branch 4 taken 3024 times.
10745 switch(scrolldir)
27205 {
27206 case up:
27207 {
27208
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 2982 times.
3028 if(destscr != -1)
27209 46 currscr = destscr;
27210
3/4
✓ Branch 0 taken 2937 times.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2937 times.
2982 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
27211 2937 currscr -= 16;
27212
27213 3028 loadscr(0,destdmap,currscr,scrolldir,overlay);
27214 3028 blit(scrollbuf,scrollbuf,0,0,0,176,256,176);
27215 3028 putscr(scrollbuf,0,0,newscr);
27216 3028 putscrdoors(scrollbuf,0,0,newscr);
27217 3028 sy=176;
27218
27219
2/2
✓ Branch 0 taken 2701 times.
✓ Branch 1 taken 327 times.
3028 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) == 0)
27220 327 sy+=3;
27221
27222 3028 cx=176/step;
27223 3028 FFCore.init_combo_doscript();
27224 }
27225 3028 break;
27226
27227 case down:
27228 {
27229
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 2120 times.
2174 if(destscr != -1)
27230 54 currscr = destscr;
27231
3/4
✓ Branch 0 taken 2102 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2102 times.
2120 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
27232 2102 currscr += 16;
27233
27234 2174 loadscr(0,destdmap,currscr,scrolldir,overlay);
27235 2174 putscr(scrollbuf,0,176,newscr);
27236 2174 putscrdoors(scrollbuf,0,176,newscr);
27237 2174 sy = 0;
27238
27239
2/2
✓ Branch 0 taken 2019 times.
✓ Branch 1 taken 155 times.
2174 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) == 0)
27240 155 sy+=3;
27241
27242 2174 cx = 176 / step;
27243 2174 FFCore.init_combo_doscript();
27244 }
27245 2174 break;
27246
27247 case left:
27248 {
27249
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 2451 times.
2518 if(destscr!=-1)
27250 67 currscr = destscr;
27251
3/4
✓ Branch 0 taken 2433 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2433 times.
2451 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
27252 2433 --currscr;
27253
27254 2518 loadscr(0,destdmap,currscr,scrolldir,overlay);
27255 2518 blit(scrollbuf,scrollbuf,0,0,256,0,256,176);
27256 2518 putscr(scrollbuf,0,0,newscr);
27257 2518 putscrdoors(scrollbuf,0,0,newscr);
27258 2518 sx = 256;
27259 2518 cx = 256 / step;
27260 2518 FFCore.init_combo_doscript();
27261 }
27262 2518 break;
27263
27264 case right:
27265 {
27266
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 2876 times.
3024 if(destscr != -1)
27267 148 currscr = destscr;
27268
3/4
✓ Branch 0 taken 2849 times.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2849 times.
2876 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
27269 2849 ++currscr;
27270
27271 3024 loadscr(0,destdmap,currscr,scrolldir,overlay);
27272 3024 putscr(scrollbuf,256,0,newscr);
27273 3024 putscrdoors(scrollbuf,256,0,tmpscr);
27274 3024 sx = 0;
27275 3024 cx = 256 / step;
27276 3024 FFCore.init_combo_doscript();
27277 }
27278 3024 break;
27279 }
27280
27281 // change Hero's state if entering water
27282 10745 int32_t ahead = lookahead(scrolldir);
27283 10745 int32_t aheadflag = lookaheadflag(scrolldir);
27284 10745 int32_t lookaheadx = vbound(x+8,0,240); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
27285 10745 int32_t lookaheady = vbound(y + (bigHitbox?8:12),0,160);
27286 10745 int32_t wateraheadx1 = vbound(x+4,0,240);
27287 10745 int32_t wateraheadx2 = vbound(x+11,0,240);;
27288 10745 int32_t wateraheady1 = vbound(y+9,0,160);
27289 10745 int32_t wateraheady2 = vbound(y+15,0,160);
27290 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
27291 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
27292 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
27293
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3027 times.
✓ Branch 2 taken 2174 times.
✓ Branch 3 taken 2518 times.
✓ Branch 4 taken 3024 times.
10745 switch(scrolldir)
27294 {
27295 case up:
27296 3027 lookaheady=160;
27297 3027 wateraheady1=160;
27298 3027 wateraheady2=160;
27299 3027 break;
27300
27301 case down:
27302 2174 lookaheady=0;
27303 2174 wateraheady1=0;
27304 2174 wateraheady2=0;
27305 2174 break;
27306
27307 case left:
27308 2518 lookaheadx=240;
27309 2518 wateraheadx1=240;
27310 2518 wateraheadx2=240;
27311 2518 break;
27312
27313 case right:
27314 3024 lookaheadx=0;
27315 3024 wateraheadx1=0;
27316 3024 wateraheadx2=0;
27317 3024 break;
27318 }
27319
27320 10743 bool nowinwater = false;
27321
27322
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 10677 times.
10743 if(lastaction != inwind)
27323 {
27324
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 10481 times.
10677 if(lastaction == rafting ) //&& isRaftFlag(aheadflag))
27325 {
27326
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 189 times.
196 if (lookaheadraftflag(scrolldir))
27327 {
27328 189 action=rafting; FFCore.setHeroAction(rafting);
27329 189 raftclk=0;
27330 189 }
27331 196 }
27332
5/6
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 10304 times.
✓ Branch 2 taken 177 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✓ Branch 5 taken 156 times.
10481 else if(iswaterex(ahead, currmap, currscr, -1, wateraheadx1,wateraheady1) && iswaterex(ahead, currmap, currscr, -1, wateraheadx2,wateraheady2) && (current_item(itype_flippers)))
27333 {
27334
9/16
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 146 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 10 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 10 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 10 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 10 times.
✗ Branch 15 not taken.
156 if(lastaction==swimming || lastaction == sideswimming || lastaction == sideswimattacking || lastaction == sideswimhit || lastaction == swimhit || lastaction == sideswimcasting || lastaction == sidewaterhold1 || lastaction == sidewaterhold2)
27335 {
27336 146 SetSwim();
27337 146 hopclk = 0xFF;
27338 146 nowinwater = true;
27339 146 }
27340 else
27341 {
27342 10 action=hopping; FFCore.setHeroAction(hopping);
27343 10 hopclk = 2;
27344 10 nowinwater = true;
27345 }
27346 156 }
27347
3/4
✓ Branch 0 taken 10312 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10325 times.
10325 else if((lastaction == attacking || lastaction == sideswimattacking) && charging)
27348 {
27349 action = lastaction; FFCore.setHeroAction(lastaction);
27350 }
27351 else
27352 {
27353 10325 action=none; FFCore.setHeroAction(none);
27354 }
27355 10677 }
27356
27357
1/2
✓ Branch 0 taken 10743 times.
✗ Branch 1 not taken.
10743 isForceFaceUp = isForceFaceUp && canSideviewLadderRemote(lookaheadx,lookaheady);
27358
27359 // The naturaldark state can be read/set by an FFC script before
27360 // fade() or lighting() is called.
27361 10743 naturaldark = ((TheMaps[currmap*MAPSCRS+currscr].flags & fDARK) != 0);
27362
27363
2/2
✓ Branch 0 taken 10511 times.
✓ Branch 1 taken 232 times.
10743 if(newscr->oceansfx != oldscr->oceansfx) adjust_sfx(oldscr->oceansfx, 128, false);
27364
27365
2/2
✓ Branch 0 taken 10500 times.
✓ Branch 1 taken 243 times.
10743 if(newscr->bosssfx != oldscr->bosssfx) adjust_sfx(oldscr->bosssfx, 128, false);
27366 //Preloaded ffc scripts
27367 10743 homescr=currscr;
27368 10743 auto olddmap = currdmap;
27369
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 10428 times.
10743 auto newdmap = (destdmap >= 0) ? destdmap : currdmap;
27370
27371 10743 currdmap = newdmap;
27372 10743 ffscript_engine(true);
27373 10743 currdmap = olddmap;
27374
27375 // There are two occasions when scrolling must be darkened:
27376 // 1) When scrolling into a dark room.
27377 // 2) When scrolling between DMaps of different colours.
27378
4/4
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 10428 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 125 times.
10743 if(destdmap != -1 && DMaps[destdmap].color != currcset)
27379 {
27380
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 fade((specialcave > 0) ? (specialcave >= GUYCAVE) ? 10 : 11 : currcset, true, false);
27381 125 darkroom = true;
27382 125 }
27383
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 10441 times.
10618 else if(!darkroom)
27384 10441 lighting(false, false); // NES behaviour: fade to dark before scrolling
27385
27386
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 10547 times.
10743 if(action != rafting) // Is this supposed to be here?!
27387
27388 10547 cx++; //This was the easiest way to re-arrange the loop so drawing is in the middle
27389
27390 10743 cx *= delay; //so we can have drawing re-done every frame,
27391 //previously it was for(0 to delay) advanceframes at end of loop
27392 10743 int32_t no_move = 0;
27393
27394 10743 currdmap = newdmap;
27395
4/4
✓ Branch 0 taken 10743 times.
✓ Branch 1 taken 698721 times.
✓ Branch 2 taken 698721 times.
✓ Branch 3 taken 10743 times.
709464 for(word i = 0; cx >= 0 && delay != 0; i++, cx--) //Go!
27396 {
27397
3/4
✓ Branch 0 taken 698721 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 577272 times.
✓ Branch 3 taken 121449 times.
698721 if (replay_is_active() && replay_get_version() < 3)
27398 {
27399 121449 replay_poll();
27400 121449 }
27401
1/2
✓ Branch 0 taken 698721 times.
✗ Branch 1 not taken.
698721 if(Quit)
27402 {
27403 screenscrolling = false;
27404 return;
27405 }
27406
27407
27408 698721 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false);
27409
27410
2/2
✓ Branch 0 taken 644854 times.
✓ Branch 1 taken 53867 times.
698721 if(no_move > 0)
27411 53867 no_move--;
27412
27413 //Don't want to move things on the first or last iteration, or between delays
27414
6/6
✓ Branch 0 taken 687978 times.
✓ Branch 1 taken 10743 times.
✓ Branch 2 taken 672516 times.
✓ Branch 3 taken 15462 times.
✓ Branch 4 taken 23129 times.
✓ Branch 5 taken 649387 times.
698721 if(i == 0 || cx == 0 || cx % delay != 0)
27415 49334 no_move++;
27416
27417
4/4
✓ Branch 0 taken 524511 times.
✓ Branch 1 taken 174210 times.
✓ Branch 2 taken 118651 times.
✓ Branch 3 taken 405860 times.
698721 if(scrolldir == up || scrolldir == down)
27418 {
27419
2/2
✓ Branch 0 taken 257684 times.
✓ Branch 1 taken 35177 times.
292861 if(!get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING))
27420 {
27421 //Add a few extra frames if on the second loop and cool scrolling is not set
27422
2/2
✓ Branch 0 taken 34695 times.
✓ Branch 1 taken 482 times.
35177 if(i == 1)
27423 {
27424 482 cx += (scrolldir == down) ? 3 : 2;
27425 482 no_move += (scrolldir == down) ? 3 : 2;
27426 482 }
27427 35177 }
27428 else
27429 {
27430 //4 frames after we've finished scrolling of being still
27431
4/4
✓ Branch 0 taken 9438 times.
✓ Branch 1 taken 248246 times.
✓ Branch 2 taken 4719 times.
✓ Branch 3 taken 4719 times.
257684 if(cx == 0 && !end_frames)
27432 {
27433 4719 cx += 4;
27434 4719 no_move += 4;
27435 4719 end_frames = true;
27436 4719 }
27437 }
27438 292861 }
27439
27440 //Move Hero and the scroll position
27441
2/2
✓ Branch 0 taken 64610 times.
✓ Branch 1 taken 634111 times.
698721 if(!no_move)
27442 {
27443
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 140576 times.
✓ Branch 2 taken 98759 times.
✓ Branch 3 taken 178737 times.
✓ Branch 4 taken 216039 times.
634111 switch(scrolldir)
27444 {
27445 case up:
27446 140576 sy -= step;
27447 140576 y += step;
27448 140576 break;
27449
27450 case down:
27451 98759 sy += step;
27452 98759 y -= step;
27453 98759 break;
27454
27455 case left:
27456 178737 sx -= step;
27457 178737 x += step;
27458 178737 break;
27459
27460 case right:
27461 216039 sx += step;
27462 216039 x -= step;
27463 216039 break;
27464 }
27465
27466 //bound Hero when me move him off the screen in the last couple of frames of scrolling
27467
2/2
✓ Branch 0 taken 12436 times.
✓ Branch 1 taken 621675 times.
634111 if(y > 160) y = 160;
27468
27469
2/2
✓ Branch 0 taken 8659 times.
✓ Branch 1 taken 625452 times.
634111 if(y < 0) y = 0;
27470
27471
2/2
✓ Branch 0 taken 11127 times.
✓ Branch 1 taken 622984 times.
634111 if(x > 240) x = 240;
27472
27473
2/2
✓ Branch 0 taken 13449 times.
✓ Branch 1 taken 620662 times.
634111 if(x < 0) x = 0;
27474
27475
4/4
✓ Branch 0 taken 633865 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 633855 times.
634111 if(ladderx > 0 || laddery > 0)
27476 {
27477 // If the ladder moves on both axes, the player can
27478 // gradually shift it by going back and forth
27479
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
256 if(scrolldir==up || scrolldir==down)
27480 laddery = y.getInt();
27481 else
27482 256 ladderx = x.getInt();
27483 256 }
27484 634111 }
27485
27486 //Drawing
27487 698721 tx = sx;
27488 698721 ty = sy;
27489 698721 tx2 = sx;
27490 698721 ty2 = sy;
27491
27492
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 222087 times.
✓ Branch 2 taken 118651 times.
✓ Branch 3 taken 183773 times.
✓ Branch 4 taken 174210 times.
698721 switch(scrolldir)
27493 {
27494 case right:
27495 222087 FFCore.ScrollingData[SCROLLDATA_NX] = 256-tx2;
27496 222087 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
27497 222087 FFCore.ScrollingData[SCROLLDATA_OX] = -tx2;
27498 222087 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27499 222087 tx -= 256;
27500 222087 break;
27501
27502 case down:
27503 118651 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
27504 118651 FFCore.ScrollingData[SCROLLDATA_NY] = 176-ty2;
27505 118651 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27506 118651 FFCore.ScrollingData[SCROLLDATA_OY] = -ty2;
27507 118651 ty -= 176;
27508 118651 break;
27509
27510 case left:
27511 183773 FFCore.ScrollingData[SCROLLDATA_NX] = -tx2;
27512 183773 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
27513 183773 FFCore.ScrollingData[SCROLLDATA_OX] = 256-tx2;
27514 183773 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27515 183773 tx2 -= 256;
27516 183773 break;
27517
27518 case up:
27519 174210 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
27520 174210 FFCore.ScrollingData[SCROLLDATA_NY] = -ty2;
27521 174210 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27522 174210 FFCore.ScrollingData[SCROLLDATA_OY] = 176-ty2;
27523 174210 ty2 -= 176;
27524 174210 break;
27525 }
27526
27527 //FFScript.OnWaitdraw()
27528 698721 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
27529
27530 698721 FFCore.runGenericPassiveEngine(SCR_TIMING_PRE_DRAW);
27531 698721 clear_bitmap(scrollbuf);
27532 698721 clear_bitmap(framebuf);
27533 698721 clear_a5_bmp(rti_infolayer.bitmap);
27534
27535 698721 combotile_add_x = 0;
27536 698721 combotile_add_y = playing_field_offset;
27537
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 174210 times.
✓ Branch 2 taken 118651 times.
✓ Branch 3 taken 183773 times.
✓ Branch 4 taken 222087 times.
698721 switch(scrolldir)
27538 {
27539 case up:
27540
1/2
✓ Branch 0 taken 174210 times.
✗ Branch 1 not taken.
174210 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
27541
27542
1/2
✓ Branch 0 taken 174210 times.
✗ Branch 1 not taken.
174210 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, -176+playing_field_offset, 3);
27543
27544
2/2
✓ Branch 0 taken 174193 times.
✓ Branch 1 taken 17 times.
174210 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
27545
27546
2/2
✓ Branch 0 taken 174193 times.
✓ Branch 1 taken 17 times.
174210 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, -176+playing_field_offset, 3);
27547
27548 // Draw both screens' background layer primitives together, after both layers' combos.
27549 // Not ideal, but probably good enough for all realistic purposes.
27550
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 174210 times.
✓ Branch 2 taken 174210 times.
✗ Branch 3 not taken.
174210 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
27551
27552
4/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 174193 times.
✓ Branch 2 taken 174193 times.
✓ Branch 3 taken 17 times.
174210 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
27553
27554 174210 combotile_add_y -= sy;
27555 174210 putscr(scrollbuf, 0, 0, newscr);
27556 174210 putscr(scrollbuf, 0, 176, oldscr);
27557 174210 break;
27558
27559 case down:
27560
1/2
✓ Branch 0 taken 118651 times.
✗ Branch 1 not taken.
118651 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, -176+playing_field_offset, 2);
27561
27562
1/2
✓ Branch 0 taken 118651 times.
✗ Branch 1 not taken.
118651 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
27563
27564
1/2
✓ Branch 0 taken 118651 times.
✗ Branch 1 not taken.
118651 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, -176+playing_field_offset, 2);
27565
27566
1/2
✓ Branch 0 taken 118651 times.
✗ Branch 1 not taken.
118651 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
27567
27568
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 118651 times.
✓ Branch 2 taken 118651 times.
✗ Branch 3 not taken.
118651 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
27569
27570
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 118651 times.
✓ Branch 2 taken 118651 times.
✗ Branch 3 not taken.
118651 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
27571
27572 118651 combotile_add_y -= sy;
27573 118651 putscr(scrollbuf, 0, 0, oldscr);
27574 118651 putscr(scrollbuf, 0, 176, newscr);
27575 118651 break;
27576
27577 case left:
27578
2/2
✓ Branch 0 taken 183707 times.
✓ Branch 1 taken 66 times.
183773 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
27579
27580
2/2
✓ Branch 0 taken 183707 times.
✓ Branch 1 taken 66 times.
183773 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, -256, playing_field_offset, 3);
27581
27582
2/2
✓ Branch 0 taken 183755 times.
✓ Branch 1 taken 18 times.
183773 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
27583
27584
2/2
✓ Branch 0 taken 183755 times.
✓ Branch 1 taken 18 times.
183773 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, -256, playing_field_offset, 3);
27585
27586
4/4
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 183707 times.
✓ Branch 2 taken 183641 times.
✓ Branch 3 taken 132 times.
183773 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
27587
27588
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 183755 times.
✓ Branch 2 taken 183755 times.
✓ Branch 3 taken 18 times.
183773 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
27589
27590 183773 combotile_add_x -= sx;
27591 183773 putscr(scrollbuf, 0, 0, newscr);
27592 183773 putscr(scrollbuf, 256, 0, oldscr);
27593 183773 break;
27594
27595 case right:
27596
2/2
✓ Branch 0 taken 221955 times.
✓ Branch 1 taken 132 times.
222087 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, -256, playing_field_offset, 2);
27597
27598
1/2
✓ Branch 0 taken 222087 times.
✗ Branch 1 not taken.
222087 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
27599
27600
1/2
✓ Branch 0 taken 222087 times.
✗ Branch 1 not taken.
222087 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, -256, playing_field_offset, 2);
27601
27602
1/2
✓ Branch 0 taken 222087 times.
✗ Branch 1 not taken.
222087 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
27603
27604
4/4
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 221955 times.
✓ Branch 2 taken 221955 times.
✓ Branch 3 taken 132 times.
222087 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
27605
27606
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 222087 times.
✓ Branch 2 taken 222087 times.
✗ Branch 3 not taken.
222087 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
27607
27608 222087 combotile_add_x -= sx;
27609 222087 putscr(scrollbuf, 0, 0, oldscr);
27610 222087 putscr(scrollbuf, 256, 0, newscr);
27611 222087 break;
27612 }
27613
27614 698721 combotile_add_x = 0;
27615 698721 combotile_add_y = 0;
27616
27617 698721 blit(scrollbuf, framebuf, sx, sy, 0, playing_field_offset, 256, 168);
27618 698721 do_primitives(framebuf, 0, newscr, 0, playing_field_offset);
27619
27620 698721 do_layer(framebuf, 0, 1, oldscr, tx2, ty2, 3);
27621 698721 do_layer(framebuf, 0, 1, newscr, tx, ty, 2, false, true);
27622
27623
2/2
✓ Branch 0 taken 648289 times.
✓ Branch 1 taken 50432 times.
698721 if(get_bit(quest_rules, qr_FFCSCROLL))
27624 {
27625 50432 do_layer(framebuf, -3, 0, oldscr, tx2, ty2, 3, true); //ffcs
27626 50432 do_layer(framebuf, -3, 0, newscr, tx, ty, 2, true);
27627 50432 }
27628
27629
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 698655 times.
698721 if(!(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) ) do_layer(framebuf, 0, 2, oldscr, tx2, ty2, 3);
27630
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 698523 times.
698721 if(!(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, newscr, tx, ty, 2, false, !(oldscr->flags7&fLAYER2BG));
27631
27632 //push blocks
27633 698721 do_layer(framebuf, -2, 0, oldscr, tx2, ty2, 3);
27634 698721 do_layer(framebuf, -2, 0, newscr, tx, ty, 2);
27635
2/2
✓ Branch 0 taken 689963 times.
✓ Branch 1 taken 8758 times.
698721 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
27636 {
27637 8758 do_layer(framebuf, -2, 1, oldscr, tx2, ty2, 3);
27638 8758 do_layer(framebuf, -2, 1, newscr, tx, ty, 2);
27639 8758 do_layer(framebuf, -2, 2, oldscr, tx2, ty2, 3);
27640 8758 do_layer(framebuf, -2, 2, newscr, tx, ty, 2);
27641 8758 }
27642
27643 698721 do_walkflags(oldscr, tx2, ty2,3); //show walkflags if the cheat is on
27644 698721 do_walkflags(newscr, tx, ty,2);
27645
27646 698721 do_effectflags(oldscr, tx2, ty2,3); //show effectflags if the cheat is on
27647 698721 do_effectflags(newscr, tx, ty,2);
27648
27649
27650 698721 putscrdoors(framebuf, 0-tx2, 0-ty2+playing_field_offset, oldscr);
27651 698721 putscrdoors(framebuf, 0-tx, 0-ty+playing_field_offset, newscr);
27652 698721 herostep();
27653
1/2
✓ Branch 0 taken 698721 times.
✗ Branch 1 not taken.
698721 if(isForceFaceUp) dir = up;
27654
27655
5/6
✓ Branch 0 taken 698671 times.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 698621 times.
✓ Branch 4 taken 698671 times.
✓ Branch 5 taken 698671 times.
698721 if((z > 0 || fakez > 0) && (!get_bit(quest_rules,qr_SHADOWSFLICKER) || frame&1))
27656 {
27657 1397292 drawshadow(framebuf, get_bit(quest_rules, qr_TRANSSHADOWS) != 0);
27658 1397292 }
27659
27660
4/4
✓ Branch 0 taken 355399 times.
✓ Branch 1 taken 343322 times.
✓ Branch 2 taken 126247 times.
✓ Branch 3 taken 229152 times.
698721 if(!isdungeon() || get_bit(quest_rules,qr_FREEFORM))
27661 {
27662 469569 draw_under(framebuf); //draw the ladder or raft
27663 469569 decorations.draw2(framebuf, true);
27664 469569 draw(framebuf); //Hero
27665 469569 decorations.draw(framebuf, true);
27666 469569 }
27667
27668
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 698686 times.
698721 if(!(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, oldscr, tx2, ty2, 3);
27669
27670 698721 do_layer(framebuf, 0, 4, oldscr, tx2, ty2, 3); //layer 4
27671 698721 do_layer(framebuf, -1, 0, oldscr, tx2, ty2, 3); //overhead combos
27672
2/2
✓ Branch 0 taken 692850 times.
✓ Branch 1 taken 5871 times.
698721 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
27673 {
27674 5871 do_layer(framebuf, -1, 1, oldscr, tx2, ty2, 3); //overhead combos
27675 5871 do_layer(framebuf, -1, 2, oldscr, tx2, ty2, 3); //overhead combos
27676 5871 }
27677 698721 do_layer(framebuf, 0, 5, oldscr, tx2, ty2, 3); //layer 5
27678 698721 do_layer(framebuf, -4, 0, oldscr, tx2, ty2, 3, true); //overhead FFCs
27679 698721 do_layer(framebuf, 0, 6, oldscr, tx2, ty2, 3); //layer 6
27680
27681
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 698686 times.
698721 if(!(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, newscr, tx, ty, 2, false, !(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)));
27682
27683 698721 do_layer(framebuf, 0, 4, newscr, tx, ty, 2, false, true); //layer 4
27684 698721 do_layer(framebuf, -1, 0, newscr, tx, ty, 2); //overhead combos
27685
2/2
✓ Branch 0 taken 692850 times.
✓ Branch 1 taken 5871 times.
698721 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
27686 {
27687 5871 do_layer(framebuf, -1, 1, newscr, tx, ty, 2); //overhead combos
27688 5871 do_layer(framebuf, -1, 2, newscr, tx, ty, 2); //overhead combos
27689 5871 }
27690 698721 do_layer(framebuf, 0, 5, newscr, tx, ty, 2, false, true); //layer 5
27691 698721 do_layer(framebuf, -4, 0, newscr, tx, ty, 2, true); //overhead FFCs
27692 698721 do_layer(framebuf, 0, 6, newscr, tx, ty, 2, false, true); //layer 6
27693
27694
27695
1/2
✓ Branch 0 taken 698721 times.
✗ Branch 1 not taken.
698721 if(msg_bg_display_buf->clip == 0)
27696 {
27697 blit_msgstr_bg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
27698 }
27699
1/2
✓ Branch 0 taken 698721 times.
✗ Branch 1 not taken.
698721 if(msg_portrait_display_buf->clip == 0)
27700 {
27701 blit_msgstr_prt(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
27702 }
27703
1/2
✓ Branch 0 taken 698721 times.
✗ Branch 1 not taken.
698721 if(msg_txt_display_buf->clip == 0)
27704 {
27705 blit_msgstr_fg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
27706 }
27707
27708
6/6
✓ Branch 0 taken 12165 times.
✓ Branch 1 taken 686556 times.
✓ Branch 2 taken 11939 times.
✓ Branch 3 taken 226 times.
✓ Branch 4 taken 83 times.
✓ Branch 5 taken 11856 times.
698721 if(get_bit(quest_rules, qr_NEW_DARKROOM) && ((newscr->flags&fDARK)||(oldscr->flags&fDARK)))
27709 {
27710 309 clear_to_color(darkscr_bmp_curscr, game->get_darkscr_color());
27711 309 clear_to_color(darkscr_bmp_curscr_trans, game->get_darkscr_color());
27712 309 clear_to_color(darkscr_bmp_scrollscr, game->get_darkscr_color());
27713 309 clear_to_color(darkscr_bmp_scrollscr_trans, game->get_darkscr_color());
27714 309 calc_darkroom_combos(true);
27715 309 calc_darkroom_hero(FFCore.ScrollingData[SCROLLDATA_NX], FFCore.ScrollingData[SCROLLDATA_NY],FFCore.ScrollingData[SCROLLDATA_OX], FFCore.ScrollingData[SCROLLDATA_OY]);
27716 309 }
27717
27718
4/4
✓ Branch 0 taken 12165 times.
✓ Branch 1 taken 686556 times.
✓ Branch 2 taken 8646 times.
✓ Branch 3 taken 3519 times.
698721 if(get_bit(quest_rules, qr_NEW_DARKROOM) && get_bit(quest_rules, qr_NEWDARK_L6))
27719 {
27720 3519 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
27721 3519 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
27722 3519 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
27723
1/2
✓ Branch 0 taken 3519 times.
✗ Branch 1 not taken.
3519 if(newscr->flags & fDARK)
27724 {
27725 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
27726 {
27727 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
27728 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
27729 }
27730
27731 color_map = &trans_table2;
27732 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
27733 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
27734 else
27735 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
27736 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
27737 color_map = &trans_table;
27738 }
27739
1/2
✓ Branch 0 taken 3519 times.
✗ Branch 1 not taken.
3519 if(oldscr->flags & fDARK)
27740 {
27741 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
27742 {
27743 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
27744 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
27745 }
27746
27747 color_map = &trans_table2;
27748 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
27749 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
27750 else
27751 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
27752 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
27753 color_map = &trans_table;
27754 }
27755 3519 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
27756 3519 }
27757 698721 put_passive_subscr(framebuf, &QMisc, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
27758
2/2
✓ Branch 0 taken 520438 times.
✓ Branch 1 taken 178283 times.
698721 if(get_bit(quest_rules,qr_SUBSCREENOVERSPRITES))
27759 178283 do_primitives(framebuf, 7, newscr, 0, playing_field_offset);
27760
27761
4/4
✓ Branch 0 taken 12165 times.
✓ Branch 1 taken 686556 times.
✓ Branch 2 taken 8646 times.
✓ Branch 3 taken 3519 times.
698721 if(get_bit(quest_rules, qr_NEW_DARKROOM) && !get_bit(quest_rules, qr_NEWDARK_L6))
27762 {
27763 8646 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
27764 8646 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
27765 8646 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
27766
2/2
✓ Branch 0 taken 8420 times.
✓ Branch 1 taken 226 times.
8646 if(newscr->flags & fDARK)
27767 {
27768
1/2
✓ Branch 0 taken 226 times.
✗ Branch 1 not taken.
226 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
27769 {
27770 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
27771 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
27772 }
27773
27774 226 color_map = &trans_table2;
27775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
226 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
27776 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
27777 else
27778 226 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
27779 226 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
27780 226 color_map = &trans_table;
27781 226 }
27782
2/2
✓ Branch 0 taken 8437 times.
✓ Branch 1 taken 209 times.
8646 if(oldscr->flags & fDARK)
27783 {
27784
1/2
✓ Branch 0 taken 209 times.
✗ Branch 1 not taken.
209 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
27785 {
27786 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
27787 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
27788 }
27789
27790 209 color_map = &trans_table2;
27791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 209 times.
209 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
27792 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
27793 else
27794 209 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
27795 209 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
27796 209 color_map = &trans_table;
27797 209 }
27798 8646 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
27799 8646 }
27800 698721 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DRAW);
27801
27802 //end drawing
27803 698721 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
27804 698721 advanceframe(true/*,true,false*/);
27805
27806 //Don't clear the last frame, unless 'fixed'
27807
4/4
✓ Branch 0 taken 10743 times.
✓ Branch 1 taken 687978 times.
✓ Branch 2 taken 241 times.
✓ Branch 3 taken 10502 times.
698721 if(cx > 0 || get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
27808 688219 script_drawing_commands.Clear();
27809 698721 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
27810 698721 actiontype lastaction = action;
27811 698721 action=scrolling; FFCore.setHeroAction(scrolling);
27812 698721 FFCore.runF6Engine();
27813 698721 action=lastaction; FFCore.setHeroAction(lastaction);
27814 698721 } //end main scrolling loop
27815 10743 currdmap = olddmap;
27816
27817 10743 clear_bitmap(msg_txt_display_buf);
27818 10743 set_clip_state(msg_txt_display_buf, 1);
27819 10743 clear_bitmap(msg_bg_display_buf);
27820 10743 set_clip_state(msg_bg_display_buf, 1);
27821 10743 clear_bitmap(msg_portrait_display_buf);
27822 10743 set_clip_state(msg_portrait_display_buf, 1);
27823
27824 //Move hero to the other side of the screen if scrolling's not turned on
27825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10743 times.
10743 if(get_bit(quest_rules, qr_NOSCROLL))
27826 {
27827 switch(scrolldir)
27828 {
27829 case up:
27830 y = 160;
27831 break;
27832
27833 case down:
27834 y = 0;
27835 break;
27836
27837 case left:
27838 x = 240;
27839 break;
27840
27841 case right:
27842 x = 0;
27843 break;
27844 }
27845 }
27846
27847
3/4
✓ Branch 0 taken 10742 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 10743 times.
✗ Branch 3 not taken.
10743 if((z > 0 || fakez > 0) && isSideViewHero())
27848 {
27849 y -= z;
27850 y -= fakez;
27851 z = 0;
27852 fakez = 0;
27853 }
27854
27855 10743 combotile_add_x = 0;
27856 10743 combotile_add_y = 0;
27857
27858 10743 set_respawn_point(false);
27859 10743 trySideviewLadder();
27860 10743 warpx = -1;
27861 10743 warpy = -1;
27862
27863 10743 screenscrolling = false;
27864 10743 FFCore.ScrollingData[SCROLLDATA_DIR] = -1;
27865 10743 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
27866 10743 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
27867 10743 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27868 10743 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27869
27870
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 10428 times.
10743 if(destdmap != -1)
27871 {
27872 315 bool changedlevel = false;
27873 315 bool changeddmap = false;
27874
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 226 times.
315 if(olddmap != destdmap)
27875 {
27876 226 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
27877 226 changeddmap = true;
27878 226 }
27879
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 79 times.
315 if(DMaps[olddmap].level != DMaps[destdmap].level)
27880 {
27881 79 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
27882 79 changedlevel = true;
27883 79 }
27884 315 dlevel = DMaps[destdmap].level;
27885 315 currdmap = destdmap;
27886
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 226 times.
315 if(changeddmap)
27887 {
27888 226 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
27889 226 }
27890
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 79 times.
315 if(changedlevel)
27891 {
27892 79 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
27893 79 }
27894 315 }
27895
27896 //if Hero is going from non-water to water, and we set his animation to "hopping" above, we must now
27897 //change it to swimming - since we have manually moved Hero onto the first tile, the hopping code
27898 //will get confused and try to hop Hero onto the next (possibly nonexistant) water tile in his current
27899 //direction. -DD
27900
27901
2/2
✓ Branch 0 taken 10587 times.
✓ Branch 1 taken 156 times.
10743 if(nowinwater)
27902 {
27903 156 SetSwim();
27904 156 hopclk = 0xFF;
27905 156 }
27906
27907 // NES behaviour: Fade to light after scrolling
27908 10743 lighting(false, false); // No, we don't need to set naturaldark...
27909
27910 10743 init_dmap();
27911 10743 putscr(scrollbuf,0,0,newscr);
27912 10743 putscrdoors(scrollbuf,0,0,newscr);
27913
27914 // Check for raft flags
27915
6/6
✓ Branch 0 taken 10547 times.
✓ Branch 1 taken 196 times.
✓ Branch 2 taken 10391 times.
✓ Branch 3 taken 156 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 10340 times.
10743 if(action!=rafting && hopclk==0 && !toogam)
27916 {
27917
3/4
✓ Branch 0 taken 10337 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10337 times.
10340 if(MAPFLAG(x,y)==mfRAFT||MAPCOMBOFLAG(x,y)==mfRAFT)
27918 {
27919 3 sfx(tmpscr->secretsfx);
27920 3 action=rafting; FFCore.setHeroAction(rafting);
27921 3 raftclk=0;
27922 3 }
27923
27924 // Half a tile off?
27925
6/8
✓ Branch 0 taken 7785 times.
✓ Branch 1 taken 2552 times.
✓ Branch 2 taken 3015 times.
✓ Branch 3 taken 4770 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5567 times.
✓ Branch 6 taken 10337 times.
✗ Branch 7 not taken.
15904 else if((dir==left || dir==right) && (MAPFLAG(x,y+8)==mfRAFT||MAPCOMBOFLAG(x,y+8)==mfRAFT))
27926 {
27927 sfx(tmpscr->secretsfx);
27928 action=rafting; FFCore.setHeroAction(rafting);
27929 raftclk=0;
27930 }
27931 10340 }
27932
27933 10743 opendoors=0;
27934 10743 markBmap(-1);
27935
27936
2/2
✓ Branch 0 taken 6322 times.
✓ Branch 1 taken 4421 times.
10743 if(isdungeon())
27937 {
27938
3/3
✓ Branch 0 taken 2562 times.
✓ Branch 1 taken 1145 times.
✓ Branch 2 taken 714 times.
4421 switch(tmpscr->door[scrolldir^1])
27939 {
27940 case dOPEN:
27941 case dUNLOCKED:
27942 case dOPENBOSS:
27943 2562 dir = scrolldir;
27944
27945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2562 times.
2562 if(action!=rafting)
27946 2562 stepforward(diagonalMovement?11:12, false);
27947
27948 2562 break;
27949
27950 case dSHUTTER:
27951 case d1WAYSHUTTER:
27952 1145 dir = scrolldir;
27953
27954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1145 times.
1145 if(action!=rafting)
27955 1145 stepforward(diagonalMovement?21:24, false);
27956
27957 1145 putdoor(scrollbuf,0,scrolldir^1,tmpscr->door[scrolldir^1]);
27958 1145 opendoors=-4;
27959 1145 sfx(WAV_DOOR);
27960 1145 break;
27961
27962 default:
27963 714 dir = scrolldir;
27964
27965
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 667 times.
714 if(action!=rafting)
27966 667 stepforward(diagonalMovement?21:24, false);
27967 714 }
27968 4421 }
27969
27970
1/2
✓ Branch 0 taken 10743 times.
✗ Branch 1 not taken.
10743 if(isForceFaceUp) dir = up;
27971
27972
1/2
✓ Branch 0 taken 10743 times.
✗ Branch 1 not taken.
10743 if(action == scrolling)
27973 {
27974 action=none; FFCore.setHeroAction(none);
27975 }
27976
27977
2/4
✓ Branch 0 taken 10743 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10743 times.
10743 if(action != attacking && action != sideswimattacking)
27978 {
27979 10743 charging = 0;
27980 10743 tapping = false;
27981 10743 }
27982
27983 10743 map_bkgsfx(true);
27984
27985
2/2
✓ Branch 0 taken 10716 times.
✓ Branch 1 taken 27 times.
10743 if(newscr->flags2&fSECRET)
27986 {
27987 27 sfx(newscr->secretsfx);
27988 27 }
27989
27990 10743 playLevelMusic();
27991
27992 10743 newscr_clk = frame;
27993 10743 activated_timed_warp=false;
27994 10743 loadside = scrolldir^1;
27995 10743 FFCore.init_combo_doscript();
27996 10743 eventlog_mapflags();
27997 10743 decorations.animate(); //continue to animate tall grass during scrolling
27998
2/2
✓ Branch 0 taken 241 times.
✓ Branch 1 taken 10502 times.
10743 if(get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
27999 {
28000 241 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
28001 241 }
28002 10743 }
28003
28004
28005
28006 // How much to reduce Hero's damage, taking into account various rings.
28007 6824 int32_t HeroClass::ringpower(int32_t dmg, bool noPeril, bool noRing)
28008 {
28009
1/2
✓ Branch 0 taken 6824 times.
✗ Branch 1 not taken.
6824 if(dmg < 0) return dmg; //Don't reduce healing
28010
2/2
✓ Branch 0 taken 6690 times.
✓ Branch 1 taken 134 times.
6824 if ( get_bit(quest_rules,qr_BROKEN_RING_POWER) )
28011 {
28012 6690 int32_t divisor = 1;
28013 6690 float percentage = 1;
28014 6690 int32_t itemid = current_item_id(itype_ring);
28015 6690 bool usering = false;
28016
28017
4/4
✓ Branch 0 taken 4845 times.
✓ Branch 1 taken 1845 times.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 4808 times.
6690 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
28018 {
28019 4808 usering = true;
28020 4808 paymagiccost(itemid);
28021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4808 times.
4808 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
28022 {
28023 percentage *= itemsbuf[itemid].power/100.0;
28024 }
28025 else
28026 {
28027 4808 divisor *= itemsbuf[itemid].power;
28028 }
28029 4808 }
28030
28031 /* Now for the Peril Ring */
28032 6690 itemid = current_item_id(itype_perilring);
28033
28034
7/10
✓ Branch 0 taken 502 times.
✓ Branch 1 taken 6188 times.
✓ Branch 2 taken 502 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75 times.
✓ Branch 5 taken 427 times.
✓ Branch 6 taken 75 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 75 times.
6690 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
28035 {
28036 75 usering = true;
28037 75 paymagiccost(itemid);
28038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
28039 {
28040 percentage *= itemsbuf[itemid].power/100.0;
28041 }
28042 else
28043 {
28044 75 divisor *= itemsbuf[itemid].power;
28045 }
28046 75 }
28047
28048 // Ring divisor of 0 = no damage. -L
28049
4/6
✓ Branch 0 taken 4815 times.
✓ Branch 1 taken 1875 times.
✓ Branch 2 taken 4815 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4815 times.
6690 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
28050 return 0;
28051
28052
1/2
✓ Branch 0 taken 6690 times.
✗ Branch 1 not taken.
6690 if( percentage < 0 ) percentage = (percentage * -1) + 1; //Negative percentage = that percent MORE damage -V
28053
28054
1/2
✓ Branch 0 taken 6690 times.
✗ Branch 1 not taken.
6690 if ( divisor < 0 ) return dmg * percentage * (divisor*-1);
28055
1/2
✓ Branch 0 taken 6690 times.
✗ Branch 1 not taken.
6690 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
28056
28057 }
28058 else
28059 {
28060 134 double divisor = 1;
28061 134 double percentage = 1;
28062 134 int32_t itemid = current_item_id(itype_ring);
28063 134 bool usering = false;
28064
28065
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 131 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
134 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
28066 {
28067 3 usering = true;
28068 3 paymagiccost(itemid);
28069
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
28070 {
28071 1 double perc = itemsbuf[itemid].power/100.0;
28072
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
28073 1 percentage *= perc;
28074 1 }
28075 else
28076 {
28077
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemsbuf[itemid].power < 0)
28078 divisor /= -(itemsbuf[itemid].power);
28079 2 else divisor *= itemsbuf[itemid].power;
28080 }
28081 3 }
28082
28083 /* Now for the Peril Ring */
28084 134 itemid = current_item_id(itype_perilring);
28085
28086
4/10
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 132 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
134 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
28087 {
28088 usering = true;
28089 paymagiccost(itemid);
28090 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
28091 {
28092 double perc = itemsbuf[itemid].power/100.0;
28093 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
28094 percentage *= perc;
28095 }
28096 else
28097 {
28098 if(itemsbuf[itemid].power < 0)
28099 divisor /= -(itemsbuf[itemid].power);
28100 else divisor *= itemsbuf[itemid].power;
28101 }
28102 }
28103
28104 // Ring divisor of 0 = no damage. -L
28105
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 131 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
134 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
28106 return 0;
28107
28108 //if ( divisor < 0 ) return dmg * percentage * (divisor*-1); //handle this further up now
28109
1/2
✓ Branch 0 taken 134 times.
✗ Branch 1 not taken.
134 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
28110 }
28111 6824 }
28112
28113 // Should swinging the hammer make the 'pound' sound?
28114 // Or is Hero just hitting air?
28115 2216 bool HeroClass::sideviewhammerpound()
28116 {
28117 2216 int32_t wx=0,wy=0;
28118
28119
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
✓ Branch 2 taken 488 times.
✓ Branch 3 taken 638 times.
✓ Branch 4 taken 740 times.
2216 switch(dir)
28120 {
28121 case up:
28122 350 wx=-1;
28123 350 wy=-15;
28124
28125
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 if(isSideViewHero()) wy+=8;
28126
28127 350 break;
28128
28129 case down:
28130 488 wx=8;
28131 488 wy=28;
28132
28133
1/2
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
488 if(isSideViewHero()) wy-=8;
28134
28135 488 break;
28136
28137 case left:
28138 638 wx=-8;
28139 638 wy=14;
28140
28141
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 6 times.
638 if(isSideViewHero()) wy+=8;
28142
28143 638 break;
28144
28145 case right:
28146 740 wx=21;
28147 740 wy=14;
28148
28149
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(isSideViewHero()) wy+=8;
28150
28151 740 break;
28152 }
28153
28154
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2210 times.
2216 if(!isSideViewHero())
28155 {
28156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2210 times.
2210 return (COMBOTYPE(x+wx,y+wy)!=cSHALLOWWATER && !iswaterex(MAPCOMBO(x+wx,y+wy), currmap, currscr, -1, x+wx,y+wy));
28157 }
28158
28159
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
28160
28161 if(dir==left || dir==right)
28162 {
28163 wx+=16;
28164
28165 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
28166 }
28167
28168 return false;
28169 2216 }
28170
28171 /************************************/
28172 /******** More Items Code *********/
28173 /************************************/
28174
28175 // The following are only used for Hero damage. Damage is in quarter hearts.
28176 3786 int32_t enemy_dp(int32_t index)
28177 {
28178 3786 return (((enemy*)guys.spr(index))->dp)*(game->get_ene_dmgmult());
28179 }
28180
28181 2890 int32_t ewpn_dp(int32_t index)
28182 {
28183 2890 return (((weapon*)Ewpns.spr(index))->power)*(game->get_ene_dmgmult());
28184 }
28185
28186 27 int32_t lwpn_dp(int32_t index)
28187 {
28188 27 return (((weapon*)Lwpns.spr(index))->power)*(game->get_ene_dmgmult());
28189 }
28190
28191 93447779 bool checkbunny(int32_t itemid)
28192 {
28193
3/4
✓ Branch 0 taken 93343113 times.
✓ Branch 1 taken 104666 times.
✓ Branch 2 taken 104666 times.
✗ Branch 3 not taken.
93447779 return !Hero.BunnyClock() || (itemid > 0 && itemsbuf[itemid].flags&ITEM_BUNNY_ENABLED);
28194 }
28195
28196 22513550 bool usesSwordJinx(int32_t itemid)
28197 {
28198 22513550 itemdata const& it = itemsbuf[itemid];
28199 22513550 bool ret = (it.family==itype_sword);
28200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22513550 times.
22513550 if(it.flags & ITEM_FLIP_JINX) return !ret;
28201 22513550 return ret;
28202 22513550 }
28203 20126964 bool checkitem_jinx(int32_t itemid)
28204 {
28205 20126964 itemdata const& it = itemsbuf[itemid];
28206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20126964 times.
20126964 if(it.flags & ITEM_JINX_IMMUNE) return true;
28207
2/2
✓ Branch 0 taken 5407818 times.
✓ Branch 1 taken 14719146 times.
20126964 if(usesSwordJinx(itemid)) return HeroSwordClk() == 0;
28208 14719146 return HeroItemClk() == 0;
28209 20126964 }
28210
28211 373095 int32_t Bweapon(int32_t pos)
28212 {
28213
4/4
✓ Branch 0 taken 373093 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 732 times.
✓ Branch 3 taken 372361 times.
373095 if(pos < 0 || current_subscreen_active == NULL)
28214 {
28215 734 return 0;
28216 }
28217
28218 372361 int32_t p=-1;
28219
28220
4/4
✓ Branch 0 taken 104120 times.
✓ Branch 1 taken 10825933 times.
✓ Branch 2 taken 104120 times.
✓ Branch 3 taken 10825933 times.
10930053 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL && i < MAXSUBSCREENITEMS; ++i)
28221 {
28222
4/4
✓ Branch 0 taken 7815600 times.
✓ Branch 1 taken 3010333 times.
✓ Branch 2 taken 7547359 times.
✓ Branch 3 taken 268241 times.
10825933 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM && current_subscreen_active->objects[i].d3==pos)
28223 {
28224 268241 p=i;
28225 268241 break;
28226 }
28227 10557692 }
28228
28229
2/2
✓ Branch 0 taken 268241 times.
✓ Branch 1 taken 104120 times.
372361 if(p==-1)
28230 {
28231 104120 return 0;
28232 }
28233
28234 268241 int32_t actualItem = current_subscreen_active->objects[p].d8;
28235 //int32_t familyCheck = actualItem ? itemsbuf[actualItem].family : current_subscreen_active->objects[p].d1
28236 268241 int32_t family = -1;
28237 268241 bool bow = false;
28238
28239
2/2
✓ Branch 0 taken 9486 times.
✓ Branch 1 taken 258755 times.
268241 if(actualItem)
28240 {
28241 9486 bool select = false;
28242
28243
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6222 times.
9486 switch(itemsbuf[actualItem-1].family)
28244 {
28245 case itype_bomb:
28246 if((game->get_bombs() ||
28247 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
28248 (actualItem-1>-1 && itemsbuf[actualItem-1].misc1==0 && findWeaponWithParent(actualItem-1, wLitBomb))) ||
28249 current_item_power(itype_bombbag))
28250 {
28251 select=true;
28252 }
28253
28254 break;
28255
28256 case itype_bowandarrow:
28257 case itype_arrow:
28258 if(actualItem-1>-1 && current_item_id(itype_bow)>-1)
28259 {
28260 //bow=(current_subscreen_active->objects[p].d1==itype_bowandarrow);
28261 select=true;
28262 }
28263
28264 break;
28265
28266 case itype_letterpotion:
28267 /*if(current_item_id(itype_potion)>-1)
28268 {
28269 select=true;
28270 }
28271 else if(current_item_id(itype_letter)>-1)
28272 {
28273 select=true;
28274 }*/
28275 break;
28276
28277 case itype_sbomb:
28278 {
28279 int32_t bombbagid = current_item_id(itype_bombbag);
28280
28281 if((game->get_sbombs() ||
28282 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
28283 (actualItem-1>-1 && itemsbuf[actualItem-1].misc1==0 && findWeaponWithParent(actualItem-1, wLitSBomb))) ||
28284 (current_item_power(itype_bombbag) && bombbagid>-1 && (itemsbuf[bombbagid].flags & ITEM_FLAG1)))
28285 {
28286 select=true;
28287 }
28288
28289 break;
28290 }
28291
28292 case itype_sword:
28293 {
28294
1/2
✓ Branch 0 taken 6222 times.
✗ Branch 1 not taken.
6222 if(!get_bit(quest_rules,qr_SELECTAWPN))
28295 break;
28296
28297 6222 select=true;
28298 }
28299 6222 break;
28300
28301 default:
28302 3264 select=true;
28303 3264 }
28304
28305
4/6
✓ Branch 0 taken 9486 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7619 times.
✓ Branch 3 taken 1867 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7619 times.
9486 if(!item_disabled(actualItem-1) && game->get_item(actualItem-1) && select)
28306 {
28307 7619 directItem = actualItem-1;
28308
28309
2/4
✓ Branch 0 taken 7619 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7619 times.
✗ Branch 3 not taken.
7619 if(directItem>-1 && itemsbuf[directItem].family == itype_arrow) bow=true;
28310
28311 7619 return actualItem-1+(bow?0xF000:0);
28312 }
28313 1867 else return 0;
28314 }
28315
28316 258755 directItem = -1;
28317
28318
6/6
✓ Branch 0 taken 26083 times.
✓ Branch 1 taken 3161 times.
✓ Branch 2 taken 213455 times.
✓ Branch 3 taken 10561 times.
✓ Branch 4 taken 4028 times.
✓ Branch 5 taken 1467 times.
258755 switch(current_subscreen_active->objects[p].d1)
28319 {
28320 case itype_bomb:
28321 {
28322 26083 int32_t bombid = current_item_id(itype_bomb);
28323
28324
4/4
✓ Branch 0 taken 5578 times.
✓ Branch 1 taken 20505 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 5545 times.
31661 if((game->get_bombs() ||
28325 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
28326
3/4
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 5490 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 88 times.
5578 (bombid>-1 && itemsbuf[bombid].misc1==0 && Lwpns.idCount(wLitBomb)>0)) ||
28327 5578 current_item_power(itype_bombbag))
28328 {
28329 20538 family=itype_bomb;
28330 20538 }
28331
28332 26083 break;
28333 }
28334
28335 case itype_bowandarrow:
28336 case itype_arrow:
28337
4/4
✓ Branch 0 taken 8961 times.
✓ Branch 1 taken 1600 times.
✓ Branch 2 taken 8960 times.
✓ Branch 3 taken 1 times.
10561 if(current_item_id(itype_bow)>-1 && current_item_id(itype_arrow)>-1)
28338 {
28339 8960 bow=(current_subscreen_active->objects[p].d1==itype_bowandarrow);
28340 8960 family=itype_arrow;
28341 8960 }
28342
28343 10561 break;
28344
28345 case itype_letterpotion:
28346
2/2
✓ Branch 0 taken 2003 times.
✓ Branch 1 taken 2025 times.
4028 if(current_item_id(itype_potion)>-1)
28347 {
28348 2003 family=itype_potion;
28349 2003 }
28350
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 489 times.
2025 else if(current_item_id(itype_letter)>-1)
28351 {
28352 489 family=itype_letter;
28353 489 }
28354
28355 4028 break;
28356
28357 case itype_sbomb:
28358 {
28359 3161 int32_t bombbagid = current_item_id(itype_bombbag);
28360 3161 int32_t sbombid = current_item_id(itype_sbomb);
28361
28362
3/4
✓ Branch 0 taken 1424 times.
✓ Branch 1 taken 1737 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
3171 if((game->get_sbombs() ||
28363 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
28364
3/4
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 1355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 69 times.
1424 (sbombid>-1 && itemsbuf[sbombid].misc1==0 && Lwpns.idCount(wLitSBomb)>0)) ||
28365
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1414 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
1424 (current_item_power(itype_bombbag) && bombbagid>-1 && (itemsbuf[bombbagid].flags & ITEM_FLAG1)))
28366 {
28367 1747 family=itype_sbomb;
28368 1747 }
28369
28370 3161 break;
28371 }
28372
28373 case itype_sword:
28374 {
28375
2/2
✓ Branch 0 taken 1437 times.
✓ Branch 1 taken 30 times.
1467 if(!get_bit(quest_rules,qr_SELECTAWPN))
28376 30 break;
28377
28378 1437 family=itype_sword;
28379 }
28380 1437 break;
28381
28382 default:
28383 213455 family=current_subscreen_active->objects[p].d1;
28384 213455 }
28385
28386
2/2
✓ Branch 0 taken 248629 times.
✓ Branch 1 taken 10126 times.
258755 if(family==-1)
28387 10126 return 0;
28388
28389
2/2
✓ Branch 0 taken 12306144 times.
✓ Branch 1 taken 18859 times.
12325003 for(int32_t j=0; j<MAXITEMS; j++)
28390 {
28391 // Find the item that matches this subscreen object.
28392
5/6
✓ Branch 0 taken 422719 times.
✓ Branch 1 taken 11883425 times.
✓ Branch 2 taken 229770 times.
✓ Branch 3 taken 192949 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 229770 times.
12306144 if(itemsbuf[j].family==family && j == current_item_id(family,false) && !item_disabled(j))
28393 {
28394 229770 return j+(bow?0xF000:0);
28395 }
28396 12076374 }
28397
28398 18859 return 0;
28399 373095 }
28400
28401 93 int32_t BWeapon_to_Pos(int32_t bweapon)
28402 {
28403
2/2
✓ Branch 0 taken 5272 times.
✓ Branch 1 taken 19 times.
5291 for (int32_t i = 0; i < MAXSUBSCREENITEMS; ++i)
28404 {
28405
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 5198 times.
5272 if (Bweapon(i) == bweapon)
28406 {
28407 74 return i;
28408 }
28409 5198 }
28410 19 return -1;
28411 93 }
28412
28413 2 void stopCaneOfByrna()
28414 {
28415
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 2 times.
42 for(int32_t i=0; i<Lwpns.Count(); i++)
28416 {
28417 40 weapon *w = ((weapon*)Lwpns.spr(i));
28418
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 2 times.
40 if(w->id==wCByrna)
28419 2 w->dead=1;
28420 40 }
28421 2 }
28422
28423 /* Crashes if used by ffscript.cpp, in case LINKITEMD
28424 void stopCaneOfByrna()
28425 {
28426 byte prnt_cane = -1;
28427 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
28428 prnt_cane = ew->parentitem;
28429 for(int32_t i=0; i<Lwpns.Count(); i++)
28430 {
28431 weapon *w = ((weapon*)Lwpns.spr(i));
28432
28433 if(w->id==wCByrna)
28434 {
28435 w->dead=1;
28436 }
28437 }
28438 if ( prnt_cane > -1 )
28439 {
28440 stop_sfx(itemsbuf[prnt_cane].usesound);
28441 }
28442 }
28443 */
28444 //Check if there are no beams, kill sfx, and reset last_cane_of_byrna_item_id
28445 6416776 void HeroClass::cleanupByrna()
28446 {
28447
2/2
✓ Branch 0 taken 6416699 times.
✓ Branch 1 taken 77 times.
6416776 if ( last_cane_of_byrna_item_id > -1 )
28448 {
28449 //al_trace("Last cane id is: %d\n", last_cane_of_byrna_item_id);
28450
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 75 times.
77 if ( !(Lwpns.idCount(wCByrna)) )
28451 {
28452 2 stop_sfx(itemsbuf[last_cane_of_byrna_item_id].usesound);
28453 2 last_cane_of_byrna_item_id = -1;
28454 2 }
28455 77 }
28456 6416776 }
28457
28458 // Used to find out if an item family is attached to one of the buttons currently pressed.
28459 2071348 bool isWpnPressed(int32_t itype)
28460 {
28461 //0xFFF for subscreen overrides
28462 //Will crash on win10 without it! -Z
28463
4/4
✓ Branch 0 taken 403821 times.
✓ Branch 1 taken 1667527 times.
✓ Branch 2 taken 368537 times.
✓ Branch 3 taken 35284 times.
2071348 if((itype==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return true;
28464
4/4
✓ Branch 0 taken 712967 times.
✓ Branch 1 taken 1323097 times.
✓ Branch 2 taken 285105 times.
✓ Branch 3 taken 427862 times.
2036064 if((itype==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return true;
28465
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1608202 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1608202 if((itype==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return true;
28466
3/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1608182 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
1608202 if((itype==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return true;
28467 1608182 return false;
28468 2071348 }
28469
28470 3714107 int32_t getWpnPressed(int32_t itype)
28471 {
28472
4/4
✓ Branch 0 taken 177199 times.
✓ Branch 1 taken 3536908 times.
✓ Branch 2 taken 171856 times.
✓ Branch 3 taken 5343 times.
3714107 if((itype==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return Bwpn;
28473
3/4
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 3708178 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 586 times.
3708764 if((itype==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return Awpn;
28474
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3708178 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3708178 if((itype==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return Xwpn;
28475
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3708178 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3708178 if((itype==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return Ywpn;
28476
28477 3708178 return -1;
28478 3714107 }
28479
28480 6419923 int32_t getRocsPressed()
28481 {
28482 6419923 int32_t jumpid = current_item_id(itype_rocs,true,true);
28483
28484
2/2
✓ Branch 0 taken 198594 times.
✓ Branch 1 taken 6221329 times.
6419923 if(unsigned(jumpid) >= MAXITEMS) jumpid = -1;
28485
28486
2/2
✓ Branch 0 taken 6221329 times.
✓ Branch 1 taken 198594 times.
6419923 if (jumpid != -1)
28487 {
28488 198594 itemdata const& itm = itemsbuf[jumpid];
28489
28490 198594 byte intbtn = byte(itm.misc2&0xFF);
28491
1/2
✓ Branch 0 taken 198594 times.
✗ Branch 1 not taken.
198594 if(getIntBtnInput(intbtn, false, true, false, false, true))
28492 return jumpid; //not pressed
28493 198594 }
28494
28495
4/4
✓ Branch 0 taken 18558 times.
✓ Branch 1 taken 6401365 times.
✓ Branch 2 taken 17436 times.
✓ Branch 3 taken 1122 times.
6419923 if((itype_rocs==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return Bwpn;
28496
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6418801 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6418801 if((itype_rocs==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return Awpn;
28497
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6418801 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6418801 if((itype_rocs==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return Xwpn;
28498
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6418801 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6418801 if((itype_rocs==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return Ywpn;
28499
28500 6418801 return -1;
28501 6419923 }
28502
28503 bool isItmPressed(int32_t itmid)
28504 {
28505 if(itmid==(Bwpn&0xFFF) && DrunkcBbtn()) return true;
28506 if(itmid==(Awpn&0xFFF) && DrunkcAbtn()) return true;
28507 if(itmid==(Xwpn&0xFFF) && DrunkcEx1btn()) return true;
28508 if(itmid==(Ywpn&0xFFF) && DrunkcEx2btn()) return true;
28509 return false;
28510 }
28511
28512 781 void selectNextAWpn(int32_t type)
28513 {
28514
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 if(!get_bit(quest_rules,qr_SELECTAWPN))
28515 return;
28516
28517
2/4
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 781 times.
✗ Branch 3 not taken.
781 int32_t ret = selectWpn_new(type, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
28518 781 Awpn = Bweapon(ret);
28519 781 directItemA = directItem;
28520 781 game->awpn = ret;
28521 781 }
28522
28523 7560 void selectNextBWpn(int32_t type)
28524 {
28525
2/4
✓ Branch 0 taken 7560 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7560 times.
7560 int32_t ret = selectWpn_new(type, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
28526 7560 Bwpn = Bweapon(ret);
28527 7560 directItemB = directItem;
28528 7560 game->bwpn = ret;
28529 7560 }
28530
28531 void selectNextXWpn(int32_t type)
28532 {
28533 if(!get_bit(quest_rules,qr_SET_XBUTTON_ITEMS)) return;
28534 int32_t ret = selectWpn_new(type, game->xwpn, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
28535 Xwpn = Bweapon(ret);
28536 directItemX = directItem;
28537 game->xwpn = ret;
28538 }
28539
28540 void selectNextYWpn(int32_t type)
28541 {
28542 if(!get_bit(quest_rules,qr_SET_YBUTTON_ITEMS)) return;
28543 int32_t ret = selectWpn_new(type, game->ywpn, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1);
28544 Ywpn = Bweapon(ret);
28545 directItemY = directItem;
28546 game->ywpn = ret;
28547 }
28548
28549 50921 void verifyAWpn()
28550 {
28551
2/2
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 49902 times.
50921 if ( (game->forced_awpn != -1) )
28552 {
28553 1019 return;
28554 }
28555
2/2
✓ Branch 0 taken 46073 times.
✓ Branch 1 taken 3829 times.
49902 if(!get_bit(quest_rules,qr_SELECTAWPN))
28556 {
28557 46073 Awpn = selectSword();
28558 46073 game->awpn = 0xFF;
28559 46073 }
28560 else
28561 {
28562 3829 game->awpn = selectWpn_new(SEL_VERIFY_RIGHT, game->awpn, game->bwpn, game->xwpn, game->ywpn);
28563 3829 Awpn = Bweapon(game->awpn);
28564 3829 directItemA = directItem;
28565 }
28566 50921 }
28567
28568 48562 void verifyBWpn()
28569 {
28570
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 47549 times.
48562 if ( (game->forced_bwpn != -1) )
28571 {
28572 1013 return;
28573 }
28574 47549 game->bwpn = selectWpn_new(SEL_VERIFY_RIGHT, game->bwpn, game->awpn, game->xwpn, game->ywpn);
28575 47549 Bwpn = Bweapon(game->bwpn);
28576 47549 directItemB = directItem;
28577 48562 }
28578
28579 48562 void verifyXWpn()
28580 {
28581
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 47549 times.
48562 if ( (game->forced_xwpn != -1) )
28582 {
28583 1013 return;
28584 }
28585
2/2
✓ Branch 0 taken 47485 times.
✓ Branch 1 taken 64 times.
47549 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
28586 64 game->xwpn = selectWpn_new(SEL_VERIFY_RIGHT, game->xwpn, game->awpn, game->bwpn, game->ywpn);
28587 47485 else game->xwpn = -1;
28588 47549 Xwpn = Bweapon(game->xwpn);
28589 47549 directItemX = directItem;
28590 48562 }
28591
28592 48562 void verifyYWpn()
28593 {
28594
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 47549 times.
48562 if ( (game->forced_ywpn != -1) )
28595 {
28596 1013 return;
28597 }
28598
2/2
✓ Branch 0 taken 47485 times.
✓ Branch 1 taken 64 times.
47549 if(get_bit(quest_rules,qr_SET_YBUTTON_ITEMS))
28599 64 game->ywpn = selectWpn_new(SEL_VERIFY_RIGHT, game->ywpn, game->awpn, game->xwpn, game->bwpn);
28600 47485 else game->ywpn = -1;
28601 47549 Ywpn = Bweapon(game->ywpn);
28602 47549 directItemY = directItem;
28603 48562 }
28604
28605 48562 void verifyBothWeapons()
28606 {
28607 48562 verifyAWpn();
28608 48562 verifyBWpn();
28609 48562 verifyXWpn();
28610 48562 verifyYWpn();
28611 48562 }
28612
28613 61485 int32_t selectWpn_new(int32_t type, int32_t startpos, int32_t forbiddenpos, int32_t fp2, int32_t fp3)
28614 {
28615 //what will be returned when all else fails.
28616 //don't return the forbiddenpos... no matter what -DD
28617
28618 61485 int32_t failpos(0);
28619
28620
6/6
✓ Branch 0 taken 59086 times.
✓ Branch 1 taken 2399 times.
✓ Branch 2 taken 58925 times.
✓ Branch 3 taken 161 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 58921 times.
61485 if(startpos == forbiddenpos || startpos == fp2 || startpos == fp3)
28621 2564 failpos = 0xFF;
28622 58921 else failpos = startpos;
28623
28624 // verify startpos
28625
3/4
✓ Branch 0 taken 61485 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2575 times.
✓ Branch 3 taken 58910 times.
61485 if(startpos < 0 || startpos >= 0xFF)
28626 2575 startpos = 0;
28627
28628
2/2
✓ Branch 0 taken 61227 times.
✓ Branch 1 taken 258 times.
61485 if(current_subscreen_active == NULL)
28629 258 return failpos;
28630
28631
4/4
✓ Branch 0 taken 9871 times.
✓ Branch 1 taken 51356 times.
✓ Branch 2 taken 721 times.
✓ Branch 3 taken 9150 times.
61227 if(type==SEL_VERIFY_RIGHT || type==SEL_VERIFY_LEFT)
28632 {
28633 52077 int32_t wpn = Bweapon(startpos);
28634
28635
6/8
✓ Branch 0 taken 48601 times.
✓ Branch 1 taken 3476 times.
✓ Branch 2 taken 48580 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 48580 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 48580 times.
52077 if(wpn != 0 && startpos != forbiddenpos && startpos != fp2 && startpos != fp3)
28636 {
28637 48580 return startpos;
28638 }
28639 3497 }
28640
28641 12647 int32_t p=-1;
28642 12647 int32_t curpos = startpos;
28643 12647 int32_t firstValidPos=-1;
28644
28645
2/2
✓ Branch 0 taken 2111 times.
✓ Branch 1 taken 275840 times.
277951 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL; ++i)
28646 {
28647
2/2
✓ Branch 0 taken 79213 times.
✓ Branch 1 taken 196627 times.
275840 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM)
28648 {
28649
4/4
✓ Branch 0 taken 155486 times.
✓ Branch 1 taken 41141 times.
✓ Branch 2 taken 144950 times.
✓ Branch 3 taken 10536 times.
196627 if(firstValidPos==-1 && current_subscreen_active->objects[i].d3>=0)
28650 {
28651 10536 firstValidPos=i;
28652 10536 }
28653
28654
2/2
✓ Branch 0 taken 186091 times.
✓ Branch 1 taken 10536 times.
196627 if(current_subscreen_active->objects[i].d3==curpos)
28655 {
28656 10536 p=i;
28657 10536 break;
28658 }
28659 186091 }
28660 265304 }
28661
28662
2/2
✓ Branch 0 taken 10536 times.
✓ Branch 1 taken 2111 times.
12647 if(p == -1)
28663 {
28664 //can't find the current position
28665 // Switch to a valid weapon if there is one; otherwise,
28666 // the selector can simply disappear
28667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2111 times.
2111 if(firstValidPos>=0)
28668 {
28669 return current_subscreen_active->objects[firstValidPos].d3;
28670 }
28671 //FAILURE
28672 else
28673 {
28674 2111 return failpos;
28675 }
28676 }
28677
28678 //remember we've been here
28679 10536 set<int32_t> oldPositions;
28680
1/2
✓ Branch 0 taken 10536 times.
✗ Branch 1 not taken.
10536 oldPositions.insert(curpos);
28681
28682 //1. Perform any shifts required by the above
28683 //2. If that's not possible, go to position 1 and reset the b weapon.
28684 //2a. -if we arrive at a position we've already visited, give up and stay there
28685 //3. Get the weapon at the new slot
28686 //4. If it's not possible, go to step 1.
28687
28688 35190 for(;;)
28689 {
28690 //shift
28691
4/5
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 5120 times.
✓ Branch 3 taken 29936 times.
✗ Branch 4 not taken.
35190 switch(type)
28692 {
28693 case SEL_LEFT:
28694 case SEL_VERIFY_LEFT:
28695 5120 curpos = current_subscreen_active->objects[p].d6;
28696 5120 break;
28697
28698 case SEL_RIGHT:
28699 case SEL_VERIFY_RIGHT:
28700 29936 curpos = current_subscreen_active->objects[p].d7;
28701 29936 break;
28702
28703 case SEL_DOWN:
28704 36 curpos = current_subscreen_active->objects[p].d5;
28705 36 break;
28706
28707 case SEL_UP:
28708 98 curpos = current_subscreen_active->objects[p].d4;
28709 98 break;
28710 }
28711
28712 //find our new position
28713 35190 p = -1;
28714
28715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1135703 times.
1135703 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL; ++i)
28716 {
28717
2/2
✓ Branch 0 taken 254001 times.
✓ Branch 1 taken 881702 times.
1135703 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM)
28718 {
28719
2/2
✓ Branch 0 taken 846512 times.
✓ Branch 1 taken 35190 times.
881702 if(current_subscreen_active->objects[i].d3==curpos)
28720 {
28721 35190 p=i;
28722 35190 break;
28723 }
28724 846512 }
28725 1100513 }
28726
28727
1/2
✓ Branch 0 taken 35190 times.
✗ Branch 1 not taken.
35190 if(p == -1)
28728 {
28729 //can't find the current position
28730 //FAILURE
28731 return failpos;
28732 }
28733
28734 //if we've already been here, give up
28735
3/4
✓ Branch 0 taken 35190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33556 times.
✓ Branch 3 taken 1634 times.
35190 if(oldPositions.find(curpos) != oldPositions.end())
28736 {
28737 1634 return failpos;
28738 }
28739
28740 //else, remember we've been here
28741
1/2
✓ Branch 0 taken 33556 times.
✗ Branch 1 not taken.
33556 oldPositions.insert(curpos);
28742
28743 //see if this weapon is acceptable
28744
9/10
✓ Branch 0 taken 33556 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9131 times.
✓ Branch 3 taken 24425 times.
✓ Branch 4 taken 8920 times.
✓ Branch 5 taken 211 times.
✓ Branch 6 taken 8910 times.
✓ Branch 7 taken 10 times.
✓ Branch 8 taken 8 times.
✓ Branch 9 taken 8902 times.
33556 if(Bweapon(curpos) != 0 && curpos != forbiddenpos && curpos != fp2 && curpos != fp3)
28745 8902 return curpos;
28746
28747 //keep going otherwise
28748 }
28749 61485 }
28750
28751 // Select the sword for the A button if the 'select A button weapon' quest rule isn't set.
28752 46169 int32_t selectSword()
28753 {
28754 46169 auto ret = current_item_id(itype_sword);
28755
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 44763 times.
46169 if(ret == -1) return 0;
28756 44763 return ret;
28757 46169 }
28758
28759 // Adding code here for allowing hardcoding a button to a specific itemclass.
28760 int32_t selectItemclass(int32_t itemclass)
28761 {
28762 int32_t ret = current_item_id(itemclass);
28763
28764 if(ret == -1)
28765 ret = 0;
28766
28767 return ret;
28768 }
28769
28770 // Used for the 'Pickup Hearts' item pickup condition.
28771 111 bool canget(int32_t id)
28772 {
28773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 return id>=0 && (game->get_maxlife()>=(itemsbuf[id].pickup_hearts*game->get_hp_per_heart()));
28774 }
28775
28776 31 void dospecialmoney(int32_t index)
28777 {
28778 31 int32_t tmp=currscr>=128?1:0;
28779 31 int32_t priceindex = ((item*)items.spr(index))->PriceIndex;
28780
28781
4/7
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11 times.
31 switch(tmpscr[tmp].room)
28782 {
28783 case rINFO: // pay for info
28784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(prices[priceindex]!=100000 ) // 100000 is a placeholder price for free items
28785 {
28786
28787
28788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!current_item_power(itype_wallet))
28789 {
28790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (game->get_spendable_rupies() < abs(prices[priceindex]))
28791 return;
28792 2 int32_t tmpprice = -abs(prices[priceindex]);
28793 2 int32_t total = game->get_drupy()-tmpprice;
28794 2 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
28795 2 game->set_drupy(game->get_drupy()-total);
28796 //game->change_drupy(-abs(prices[priceindex]));
28797 2 }
28798
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( current_item_power(itype_wallet)>0 )
28799 {
28800 game->change_drupy(0);
28801 }
28802 2 }
28803 2 rectfill(msg_bg_display_buf, 0, 0, msg_bg_display_buf->w, 80, 0);
28804 2 rectfill(msg_txt_display_buf, 0, 0, msg_txt_display_buf->w, 80, 0);
28805 2 donewmsg(QMisc.info[tmpscr[tmp].catchall].str[priceindex]);
28806 2 clear_bitmap(pricesdisplaybuf);
28807 2 set_clip_state(pricesdisplaybuf, 1);
28808 2 items.del(0);
28809
28810
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 for(int32_t i=0; i<items.Count(); i++)
28811 6 ((item*)items.spr(i))->pickup=ipDUMMY;
28812
28813 // Prevent the prices from being displayed anymore
28814
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 for(int32_t i=0; i<3; i++)
28815 {
28816 6 prices[i] = 0;
28817 6 }
28818
28819 2 break;
28820
28821 case rMONEY: // secret money
28822 {
28823 14 ((item*)items.spr(0))->pickup = ipDUMMY;
28824
28825 14 prices[0] = tmpscr[tmp].catchall;
28826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (!current_item_power(itype_wallet))
28827 14 game->change_drupy(prices[0]);
28828 //game->set_drupy(game->get_drupy()+price); may be needed everywhere
28829
28830 14 putprices(false);
28831
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
28832 14 break;
28833 }
28834
28835 case rGAMBLE: // gamble
28836 {
28837 if(game->get_spendable_rupies()<10 && !current_item_power(itype_wallet)) return; //Why 10?
28838
28839 unsigned si=(zc_oldrand()%24)*3;
28840
28841 for(int32_t i=0; i<3; i++)
28842 prices[i]=gambledat[si++];
28843
28844 game->set_drupy(game->get_drupy()+prices[priceindex]);
28845 putprices(true);
28846
28847 for(int32_t i=1; i<4; i++)
28848 ((item*)items.spr(i))->pickup=ipDUMMY;
28849 }
28850 break;
28851
28852 case rBOMBS:
28853 {
28854
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
28855 return;
28856
28857 4 int32_t price = -tmpscr[tmp].catchall;
28858 4 int32_t wmedal = current_item_id(itype_wealthmedal);
28859
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(wmedal >= 0)
28860 {
28861 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
28862 price*=(itemsbuf[wmedal].misc1/100.0);
28863 else
28864 price+=itemsbuf[wmedal].misc1;
28865 }
28866
28867 4 int32_t total = game->get_drupy()-price;
28868 4 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
28869 4 game->set_drupy(game->get_drupy()-total);
28870 //game->set_drupy(game->get_drupy()+price);
28871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
28872 4 game->change_maxbombs(4);
28873 4 game->set_bombs(game->get_maxbombs());
28874 {
28875 4 int32_t div = zinit.bomb_ratio;
28876
28877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(div > 0)
28878 4 game->change_maxcounter(4/div, 6);
28879 }
28880
28881 //also give Hero an actual Bomb item
28882
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i=0; i<MAXITEMS; i++)
28883 {
28884
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1018 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
1024 if(itemsbuf[i].family == itype_bomb && itemsbuf[i].fam_type == 1)
28885 4 getitem(i, true, true);
28886 1024 }
28887
28888 4 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
28889 4 fadeclk=66;
28890 4 dismissmsg();
28891 4 clear_bitmap(pricesdisplaybuf);
28892 4 set_clip_state(pricesdisplaybuf, 1);
28893 // putscr(scrollbuf,0,0,tmpscr);
28894 4 verifyBothWeapons();
28895 4 break;
28896 }
28897
28898 case rARROWS:
28899 {
28900 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
28901 return;
28902
28903 int32_t price = -tmpscr[tmp].catchall;
28904 int32_t wmedal = current_item_id(itype_wealthmedal);
28905 if(wmedal >= 0)
28906 {
28907 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
28908 price*=(itemsbuf[wmedal].misc1/100.0);
28909 else
28910 price+=itemsbuf[wmedal].misc1;
28911 }
28912
28913 int32_t total = game->get_drupy()-price;
28914 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
28915 game->set_drupy(game->get_drupy()-total);
28916
28917 //game->set_drupy(game->get_drupy()+price);
28918 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
28919 game->change_maxarrows(10);
28920 game->set_arrows(game->get_maxarrows());
28921 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
28922 fadeclk=66;
28923 dismissmsg();
28924 clear_bitmap(pricesdisplaybuf);
28925 set_clip_state(pricesdisplaybuf, 1);
28926 // putscr(scrollbuf,0,0,tmpscr);
28927 verifyBothWeapons();
28928 break;
28929 }
28930
28931 case rSWINDLE:
28932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(items.spr(index)->id==iRupy)
28933 {
28934
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
28935 return;
28936 11 int32_t tmpprice = -tmpscr[tmp].catchall;
28937 11 int32_t total = game->get_drupy()-tmpprice;
28938 11 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
28939 11 game->set_drupy(game->get_drupy()-total);
28940 11 }
28941 else
28942 {
28943 if(game->get_maxlife()<=game->get_hp_per_heart())
28944 return;
28945
28946 game->set_life(zc_max(game->get_life()-game->get_hp_per_heart(),0));
28947 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),(game->get_hp_per_heart())));
28948 }
28949
28950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
28951 11 ((item*)items.spr(0))->pickup=ipDUMMY+ipFADE;
28952 11 ((item*)items.spr(1))->pickup=ipDUMMY+ipFADE;
28953 11 fadeclk=66;
28954 11 dismissmsg();
28955 11 clear_bitmap(pricesdisplaybuf);
28956 11 set_clip_state(pricesdisplaybuf, 1);
28957 // putscr(scrollbuf,0,0,tmpscr);
28958 11 break;
28959 }
28960 31 }
28961
28962 9599 void getitem(int32_t id, bool nosound, bool doRunPassive)
28963 {
28964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9599 times.
9599 if(unsigned(id) >= MAXITEMS)
28965 return;
28966
28967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9599 times.
9599 if (replay_is_active())
28968
1/2
✓ Branch 0 taken 9599 times.
✗ Branch 1 not taken.
9599 replay_step_comment(fmt::format("getitem {}", item_string[id]));
28969
28970
2/2
✓ Branch 0 taken 9593 times.
✓ Branch 1 taken 6 times.
9599 if(get_bit(quest_rules,qr_SCC_ITEM_COMBINES_ITEMS))
28971 {
28972 6 int32_t nextitem = -1;
28973 6 do
28974 {
28975 6 nextitem = -1;
28976
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if((itemsbuf[id].flags & ITEM_COMBINE) && game->get_item(id))
28977 // Item upgrade routine.
28978 {
28979
28980 for(int32_t i=0; i<MAXITEMS; i++)
28981 {
28982 // Find the item which is as close to this item's fam_type as possible.
28983 if(itemsbuf[i].family==itemsbuf[id].family && itemsbuf[i].fam_type>itemsbuf[id].fam_type
28984 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
28985 {
28986 nextitem = i;
28987 }
28988 }
28989
28990 if(nextitem>-1)
28991 {
28992 id = nextitem;
28993 if(!get_bit(quest_rules,qr_ITEMCOMBINE_CONTINUOUS))
28994 break; //no looping
28995 }
28996 }
28997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 } while(nextitem > -1);
28998 6 }
28999
29000 9599 itemdata const& idat = itemsbuf[id&0xFF];
29001
29002 19198 bool equipment = idat.flags &
29003 9599 ((idat.family == itype_triforcepiece) ? ITEM_FLAG8 : ITEM_GAMEDATA);
29004
29005
2/2
✓ Branch 0 taken 8665 times.
✓ Branch 1 taken 934 times.
9599 if(equipment)
29006 {
29007 // Fix boomerang sounds.
29008 934 int32_t itemid = current_item_id(idat.family);
29009
29010
4/6
✓ Branch 0 taken 547 times.
✓ Branch 1 taken 387 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
934 if(itemid>=0 && (idat.family == itype_brang || idat.family == itype_divineprotection
29011
5/6
✓ Branch 0 taken 535 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 534 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 533 times.
✓ Branch 5 taken 1 times.
535 || idat.family == itype_hookshot || idat.family == itype_switchhook || idat.family == itype_cbyrna)
29012 547 && sfx_allocated(itemsbuf[itemid].usesound)
29013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 547 times.
547 && idat.usesound != itemsbuf[itemid].usesound)
29014 {
29015 stop_sfx(itemsbuf[itemid].usesound);
29016 cont_sfx(idat.usesound);
29017 }
29018
29019 934 int32_t curitm = current_item_id(idat.family);
29020
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
934 if(!get_bit(quest_rules,qr_KEEPOLD_APPLIES_RETROACTIVELY)
29021
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 934 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
934 || curitm < 0 || (itemsbuf[curitm].fam_type <= idat.fam_type)
29022 || (itemsbuf[curitm].flags & ITEM_KEEPOLD))
29023 {
29024 934 game->set_item(id,true);
29025 934 passiveitem_script(id, doRunPassive);
29026 934 }
29027
29028
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 632 times.
934 if(!(idat.flags & ITEM_KEEPOLD))
29029 {
29030
3/4
✓ Branch 0 taken 518 times.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 518 times.
632 if(!get_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG) || current_item(idat.family)<idat.fam_type)
29031 {
29032 114 removeLowerLevelItemsOfFamily(game,itemsbuf,idat.family, idat.fam_type);
29033 114 }
29034 632 }
29035
29036 // NES consistency: replace all flying boomerangs with the current boomerang.
29037
2/2
✓ Branch 0 taken 904 times.
✓ Branch 1 taken 30 times.
934 if(idat.family==itype_brang)
29038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 for(int32_t i=0; i<Lwpns.Count(); i++)
29039 {
29040 weapon *w = ((weapon*)Lwpns.spr(i));
29041
29042 if(w->id==wBrang)
29043 {
29044 w->LOADGFX(idat.wpn);
29045 }
29046 30 }
29047 934 }
29048
29049
2/2
✓ Branch 0 taken 1571 times.
✓ Branch 1 taken 8028 times.
9599 if(idat.count!=-1)
29050 {
29051
2/2
✓ Branch 0 taken 7818 times.
✓ Branch 1 taken 210 times.
8028 if(idat.setmax)
29052 {
29053 // Bomb bags are a special case; they may be set not to increase super bombs
29054
4/6
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 203 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
210 if(idat.family==itype_bombbag && idat.count==2 && (idat.flags&16)==0)
29055 {
29056 int32_t max = game->get_maxbombs();
29057
29058 if(max<idat.max) max=idat.max;
29059
29060 game->set_maxbombs(zc_min(game->get_maxbombs()+idat.setmax,max), false);
29061 }
29062 else
29063 {
29064 210 int32_t max = game->get_maxcounter(idat.count);
29065
29066
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 177 times.
210 if(max<idat.max) max=idat.max;
29067
29068
2/2
✓ Branch 0 taken 149 times.
✓ Branch 1 taken 61 times.
210 game->set_maxcounter(zc_min(game->get_maxcounter(idat.count)+idat.setmax,max), idat.count);
29069 }
29070 210 }
29071
29072 // Amount is an uint16_t, but the range is -9999 to 16383
29073 // -1 is actually 16385 ... -9999 is 26383, and 0x8000 means use the drain counter
29074
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 7831 times.
8028 if(idat.amount&0x3FFF)
29075 {
29076
2/2
✓ Branch 0 taken 5023 times.
✓ Branch 1 taken 2808 times.
7831 if(idat.amount&0x8000)
29077 10046 game->set_dcounter(
29078
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5022 times.
5023 game->get_dcounter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
29079 else
29080 {
29081
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2808 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2808 if(idat.amount>=16385 && game->get_counter(0)<=idat.amount-16384)
29082 game->set_counter(0, idat.count);
29083 else
29084 // This is too confusing to try and change...
29085
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2808 times.
✓ Branch 2 taken 1286 times.
✓ Branch 3 taken 1522 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1286 times.
2808 game->set_counter(zc_min(game->get_counter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF),game->get_maxcounter(idat.count)), idat.count);
29086 }
29087 7831 }
29088 8028 }
29089
29090
4/4
✓ Branch 0 taken 9596 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 232 times.
✓ Branch 3 taken 9364 times.
9599 if(idat.playsound&&!nosound)
29091 {
29092 9364 sfx(idat.playsound);
29093 9364 }
29094
29095 //add lower-level items
29096
2/2
✓ Branch 0 taken 9571 times.
✓ Branch 1 taken 28 times.
9599 if(idat.flags&ITEM_GAINOLD)
29097 {
29098
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 28 times.
52 for(int32_t i=idat.fam_type-1; i>0; i--)
29099 {
29100 24 int32_t potid = getItemID(itemsbuf, idat.family, i);
29101
29102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(potid != -1)
29103 {
29104 24 game->set_item(potid, true);
29105 24 }
29106 24 }
29107 28 }
29108
29109
11/14
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 8611 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 385 times.
✓ Branch 6 taken 41 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 57 times.
✓ Branch 9 taken 53 times.
✓ Branch 10 taken 27 times.
✓ Branch 11 taken 356 times.
✓ Branch 12 taken 35 times.
✓ Branch 13 taken 5 times.
9599 switch(idat.family)
29110 {
29111 case itype_itmbundle:
29112 {
29113 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
29114 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
29115 bool pscript = (idat.flags & ITEM_FLAG1);
29116 for(auto q = 0; q < 10; ++q)
29117 {
29118 if(unsigned(ids[q]) >= MAXITEMS) continue;
29119 if(pscript)
29120 collectitem_script(ids[q]);
29121 getitem(ids[q], true, true);
29122 }
29123 }
29124 break;
29125
29126 case itype_progressive_itm:
29127 {
29128 int32_t newid = get_progressive_item(idat);
29129 if(newid > -1)
29130 getitem(newid, nosound, true);
29131 }
29132 break;
29133
29134 case itype_bottlefill:
29135 {
29136 if(idat.misc1)
29137 {
29138 game->fillBottle(idat.misc1);
29139 }
29140 }
29141 break;
29142
29143 case itype_clock:
29144 {
29145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
385 if(idat.flags & ITEM_FLAG1) //Active use, not passive
29146 break;
29147
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
385 if((idat.flags & ITEM_FLAG2) && clockclk) //"Can't activate while clock active"
29148 break;
29149 385 setClock(watch=true);
29150
29151
2/2
✓ Branch 0 taken 197120 times.
✓ Branch 1 taken 385 times.
197505 for(int32_t i=0; i<eMAXGUYS; i++)
29152 197120 clock_zoras[i]=0;
29153
29154 385 clockclk=itemsbuf[id&0xFF].misc1;
29155 385 sfx(idat.usesound);
29156 }
29157 385 break;
29158
29159 case itype_lkey:
29160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 if(game->lvlkeys[dlevel]<255) game->lvlkeys[dlevel]++;
29161 41 break;
29162
29163 case itype_ring:
29164 case itype_magicring:
29165
6/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 1 times.
25 if((get_bit(quest_rules,qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
29166 {
29167 24 ringcolor(false);
29168 24 }
29169 25 break;
29170
29171 case itype_whispring:
29172 {
29173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(idat.flags & ITEM_FLAG1)
29174 {
29175
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(HeroSwordClk()==-1) setSwordClk(150); // Let's not bother applying the divisor.
29176
29177
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(HeroItemClk()==-1) setItemClk(150); // Let's not bother applying the divisor.
29178 4 }
29179
29180
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if(idat.power==0)
29181 {
29182 2 setSwordClk(0);
29183 2 setItemClk(0);
29184 2 }
29185
29186 4 break;
29187 }
29188
29189
29190 case itype_map:
29191 57 game->lvlitems[dlevel]|=liMAP;
29192 57 break;
29193
29194 case itype_compass:
29195 53 game->lvlitems[dlevel]|=liCOMPASS;
29196 53 break;
29197
29198 case itype_bosskey:
29199 27 game->lvlitems[dlevel]|=liBOSSKEY;
29200 27 break;
29201
29202 case itype_fairy:
29203
29204
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 356 times.
✓ Branch 2 taken 119 times.
✓ Branch 3 taken 237 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 119 times.
356 game->set_life(zc_min(game->get_life()+(idat.flags&ITEM_FLAG1 ?(int32_t)(game->get_maxlife()*(idat.misc1/100.0)):((idat.misc1*game->get_hp_per_heart()))),game->get_maxlife()));
29205
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 356 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 302 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 54 times.
356 game->set_magic(zc_min(game->get_magic()+(idat.flags&ITEM_FLAG2 ?(int32_t)(game->get_maxmagic()*(idat.misc2/100.0)):((idat.misc2*game->get_mp_per_block()))),game->get_maxmagic()));
29206 356 break;
29207
29208 case itype_heartpiece:
29209 35 game->change_HCpieces(1);
29210
29211
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
35 if(game->get_HCpieces()<game->get_hcp_per_hc())
29212 28 break;
29213
29214 7 game->set_HCpieces(0);
29215
29216 7 getitem(heart_container_id());
29217 7 break;
29218
29219 case itype_killem:
29220 {
29221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(idat.flags & ITEM_FLAG1) //Active use, not passive
29222 break;
29223 5 kill_em_all();
29224 5 sfx(idat.usesound);
29225 }
29226 5 break;
29227 }
29228
29229 9599 flushItemCache();
29230 9599 update_subscreens();
29231 9599 load_Sitems(&QMisc);
29232 9599 verifyBothWeapons();
29233 9599 }
29234
29235 void takeitem(int32_t id)
29236 {
29237 game->set_item(id, false);
29238 itemdata const& idat = itemsbuf[id];
29239
29240 /* Lower the counters! */
29241 if(idat.count!=-1)
29242 {
29243 if(idat.setmax)
29244 {
29245 game->set_maxcounter(game->get_maxcounter(idat.count)-idat.setmax, idat.count);
29246 }
29247
29248 if(idat.amount&0x3FFF)
29249 {
29250 if(idat.amount&0x8000)
29251 game->set_dcounter(game->get_dcounter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
29252 else game->set_counter(game->get_counter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
29253 }
29254 }
29255
29256 switch(itemsbuf[id&0xFF].family)
29257 {
29258 // NES consistency: replace all flying boomerangs with the current boomerang.
29259 case itype_brang:
29260 if(current_item(itype_brang)) for(int32_t i=0; i<Lwpns.Count(); i++)
29261 {
29262 weapon *w = ((weapon*)Lwpns.spr(i));
29263
29264 if(w->id==wBrang)
29265 {
29266 w->LOADGFX(itemsbuf[current_item_id(itype_brang)].wpn);
29267 }
29268 }
29269
29270 break;
29271
29272 case itype_itmbundle:
29273 {
29274 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
29275 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
29276 for(auto q = 0; q < 10; ++q)
29277 {
29278 if(unsigned(ids[q]) >= MAXITEMS) continue;
29279 takeitem(ids[q]);
29280 }
29281 }
29282 break;
29283
29284 case itype_progressive_itm:
29285 {
29286 int32_t newid = get_progressive_item(idat, true);
29287 if(newid > -1)
29288 takeitem(newid);
29289 }
29290 break;
29291
29292 case itype_heartpiece:
29293 if(game->get_maxlife()>game->get_hp_per_heart())
29294 {
29295 if(game->get_HCpieces()==0)
29296 {
29297 game->set_HCpieces(game->get_hcp_per_hc());
29298 takeitem(iHeartC);
29299 }
29300
29301 game->change_HCpieces(-1);
29302 }
29303 break;
29304
29305 case itype_map:
29306 game->lvlitems[dlevel]&=~liMAP;
29307 break;
29308
29309 case itype_compass:
29310 game->lvlitems[dlevel]&=~liCOMPASS;
29311 break;
29312
29313 case itype_bosskey:
29314 game->lvlitems[dlevel]&=~liBOSSKEY;
29315 break;
29316
29317 case itype_lkey:
29318 if(game->lvlkeys[dlevel]) game->lvlkeys[dlevel]--;
29319 break;
29320
29321 case itype_ring:
29322 if((get_bit(quest_rules,qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
29323 {
29324 ringcolor(false);
29325 }
29326 break;
29327 }
29328 }
29329
29330 6929 void post_item_collect()
29331 {
29332 6929 std::vector<int32_t> &ev = FFCore.eventData;
29333 6929 ev.clear();
29334
29335 6929 throwGenScriptEvent(GENSCR_EVENT_POST_COLLECT_ITEM);
29336 6929 }
29337
29338 6979 void HeroClass::handle_triforce(int32_t id)
29339 {
29340
1/2
✓ Branch 0 taken 6979 times.
✗ Branch 1 not taken.
6979 if(unsigned(id) >= MAXITEMS)
29341 return;
29342 6979 itemdata const& itm = itemsbuf[id];
29343
2/3
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67 times.
6979 switch(itm.family)
29344 {
29345 case itype_itmbundle:
29346 {
29347 int ids[10] = {itm.misc1, itm.misc2, itm.misc3, itm.misc4, itm.misc5,
29348 itm.misc6, itm.misc7, itm.misc8, itm.misc9, itm.misc10};
29349 for(auto q = 0; q < 10; ++q)
29350 {
29351 if(unsigned(ids[q]) >= MAXITEMS) continue;
29352 handle_triforce(ids[q]);
29353 }
29354 }
29355 break;
29356 case itype_triforcepiece:
29357 {
29358
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 60 times.
67 if(itm.misc2>0)
29359 60 getTriforce(id); //small
29360 7 else getBigTri(id); //big
29361 }
29362 67 break;
29363 }
29364 6979 }
29365
29366 // Attempt to pick up an item. (-1 = check items touching Hero.)
29367 6410697 void HeroClass::checkitems(int32_t index)
29368 {
29369 6410697 int32_t tmp=currscr>=128?1:0;
29370
29371
2/2
✓ Branch 0 taken 1453 times.
✓ Branch 1 taken 6409244 times.
6410697 if(index==-1)
29372 {
29373
2/2
✓ Branch 0 taken 1309501 times.
✓ Branch 1 taken 6409244 times.
7718745 for(auto ind = items.Count()-1; ind >= 0; --ind)
29374 {
29375 1309501 item* itm = (item*)items.spr(ind);
29376
2/2
✓ Branch 0 taken 1309489 times.
✓ Branch 1 taken 12 times.
1309501 if(itm->get_forcegrab())
29377 {
29378 12 checkitems(ind);
29379 12 }
29380 1309501 }
29381
2/2
✓ Branch 0 taken 711608 times.
✓ Branch 1 taken 5697636 times.
6409244 if(diagonalMovement)
29382 {
29383 711608 index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,6,6,1);
29384 711608 }
29385 5697636 else index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,1,1,1);
29386 6409244 }
29387
29388
2/2
✓ Branch 0 taken 50801 times.
✓ Branch 1 taken 6359896 times.
6410697 if(index==-1)
29389 6359896 return;
29390
29391 // if (tmpscr[tmp].room==rSHOP && boughtsomething==true)
29392 // return;
29393 50801 item* ptr = (item*)items.spr(index);
29394 50801 int32_t pickup = ptr->pickup;
29395 50801 int8_t exstate = ptr->pickupexstate;
29396 50801 int32_t PriceIndex = ptr->PriceIndex;
29397 50801 int32_t id2 = ptr->id;
29398 50801 int32_t holdid = ptr->id;
29399 50801 int32_t pstr = ptr->pstring;
29400 50801 int32_t pstr_flags = ptr->pickup_string_flags;
29401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50801 times.
50801 if(ptr->fallclk > 0) return; //Don't pick up a falling item
29402
29403
1/2
✓ Branch 0 taken 50801 times.
✗ Branch 1 not taken.
50801 if(itemsbuf[id2].family == itype_progressive_itm)
29404 {
29405 int32_t newid = get_progressive_item(itemsbuf[id2]);
29406 if(newid > -1)
29407 {
29408 id2 = newid;
29409 holdid = newid;
29410 pstr = itemsbuf[newid].pstring;
29411 pstr_flags = itemsbuf[newid].pickup_string_flags;
29412 }
29413 }
29414
29415
2/2
✓ Branch 0 taken 49935 times.
✓ Branch 1 taken 866 times.
50801 bool bottledummy = (pickup&ipCHECK) && tmpscr[tmp].room == rBOTTLESHOP;
29416
29417
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50799 times.
50801 if(bottledummy) //Dummy bullshit!
29418 {
29419
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!game->canFillBottle())
29420 return;
29421
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
29422 {
29423 if(!current_item_power(itype_wallet))
29424 {
29425 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
29426 int32_t tmpprice = -abs(prices[PriceIndex]);
29427 //game->change_drupy(-abs(prices[priceindex]));
29428 int32_t total = game->get_drupy()-tmpprice;
29429 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
29430 game->set_drupy(game->get_drupy()-total);
29431 }
29432 else //infinite wallet
29433 {
29434 game->change_drupy(0);
29435 }
29436 }
29437 2 boughtsomething=true;
29438 //make the other shop items untouchable after
29439 //you buy something
29440 2 int32_t count = 0;
29441
29442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 for(int32_t i=0; i<3; i++)
29443 {
29444 if(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[i] != 0)
29445 {
29446 ++count;
29447 }
29448 }
29449
29450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 for(int32_t i=0; i<items.Count(); i++)
29451 {
29452 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
29453 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
29454 }
29455
29456 2 int32_t slot = game->fillBottle(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[PriceIndex]);
29457 2 id2 = find_bottle_for_slot(slot);
29458 2 ptr->id = id2;
29459 2 pstr = 0;
29460 2 pickup |= ipHOLDUP;
29461 2 }
29462 else
29463 {
29464 50799 std::vector<int32_t> &ev = FFCore.eventData;
29465 50799 ev.clear();
29466 50799 ev.push_back(id2*10000);
29467 50799 ev.push_back(pickup*10000);
29468 50799 ev.push_back(pstr*10000);
29469 50799 ev.push_back(pstr_flags*10000);
29470 50799 ev.push_back(0);
29471 50799 ev.push_back(ptr->getUID());
29472 50799 ev.push_back(GENEVT_ICTYPE_COLLECT*10000);
29473 50799 ev.push_back(0);
29474
29475 50799 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
29476 50799 bool nullify = ev[4] != 0;
29477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50799 times.
50799 if(nullify) return;
29478 50799 id2 = ev[0]/10000;
29479 50799 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
29480 50799 pstr = ev[2] / 10000;
29481 50799 pstr_flags = ev[3] / 10000;
29482
29483
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50799 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50799 if(itemsbuf[id2].family == itype_bottlefill && !game->canFillBottle())
29484 return; //No picking these up unless you have a bottle to fill!
29485
29486
5/6
✓ Branch 0 taken 48416 times.
✓ Branch 1 taken 2383 times.
✓ Branch 2 taken 42740 times.
✓ Branch 3 taken 5676 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 42740 times.
50799 if(((pickup&ipTIMER) && (ptr->clk2 < 32))&& !(pickup & ipCANGRAB))
29487
2/2
✓ Branch 0 taken 42620 times.
✓ Branch 1 taken 120 times.
42740 if(ptr->id!=iFairyMoving)
29488 // wait for it to stop flashing, doesn't check for other items yet
29489 42620 return;
29490
29491
2/2
✓ Branch 0 taken 8152 times.
✓ Branch 1 taken 27 times.
8179 if(pickup&ipENEMY) // item was being carried by enemy
29492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
54 if(more_carried_items()<=1) // 1 includes this own item.
29493 27 hasitem &= ~2;
29494
29495
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 7691 times.
8179 if(pickup&ipDUMMY) // dummy item (usually a rupee)
29496 {
29497
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 31 times.
488 if(pickup&ipMONEY)
29498 31 dospecialmoney(index);
29499
29500 488 return;
29501 }
29502
29503
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7691 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7691 if(get_bit(quest_rules,qr_HEARTSREQUIREDFIX) && !canget(id2))
29504 return;
29505
29506 7691 int32_t nextitem = -1;
29507 7691 do
29508 {
29509 7691 nextitem = -1;
29510
4/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 7677 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 10 times.
7691 if((itemsbuf[id2].flags & ITEM_COMBINE) && game->get_item(id2))
29511 // Item upgrade routine.
29512 {
29513
29514
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 10 times.
2570 for(int32_t i=0; i<MAXITEMS; i++)
29515 {
29516 // Find the item which is as close to this item's fam_type as possible.
29517
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 2538 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 10 times.
2560 if(itemsbuf[i].family==itemsbuf[id2].family && itemsbuf[i].fam_type>itemsbuf[id2].fam_type
29518
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
22 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
29519 {
29520 10 nextitem = i;
29521 10 }
29522 2560 }
29523
29524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(nextitem>-1)
29525 {
29526 10 id2 = nextitem;
29527
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(get_bit(quest_rules,qr_ITEMCOMBINE_NEW_PSTR))
29528 {
29529 pstr = itemsbuf[id2].pstring;
29530 pstr_flags = itemsbuf[id2].pickup_string_flags;
29531 }
29532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(!get_bit(quest_rules,qr_ITEMCOMBINE_CONTINUOUS))
29533 10 break; //no looping
29534 }
29535 }
29536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7681 times.
7681 } while(nextitem > -1);
29537
29538
2/2
✓ Branch 0 taken 6825 times.
✓ Branch 1 taken 866 times.
7691 if(pickup&ipCHECK) // check restrictions
29539
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 648 times.
✓ Branch 2 taken 111 times.
✓ Branch 3 taken 107 times.
866 switch(tmpscr[tmp].room)
29540 {
29541 case rSP_ITEM: // special item
29542
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 19 times.
111 if(!canget(id2)) // These ones always need the Hearts Required check
29543 19 return;
29544
29545 92 break;
29546
29547 case rP_SHOP: // potion shop
29548
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 14 times.
107 if(msg_active)
29549 93 return;
29550 [[fallthrough]];
29551 case rSHOP: // shop
29552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 662 times.
662 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
29553 {
29554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 662 times.
662 if(!current_item_power(itype_wallet))
29555 {
29556
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 62 times.
662 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
29557 62 int32_t tmpprice = -abs(prices[PriceIndex]);
29558 //game->change_drupy(-abs(prices[priceindex]));
29559 62 int32_t total = game->get_drupy()-tmpprice;
29560 62 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
29561 62 game->set_drupy(game->get_drupy()-total);
29562 62 }
29563 else //infinite wallet
29564 {
29565 game->change_drupy(0);
29566 }
29567 62 }
29568 62 boughtsomething=true;
29569 //make the other shop items untouchable after
29570 //you buy something
29571 62 int32_t count = 0;
29572
29573
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 62 times.
248 for(int32_t i=0; i<3; i++)
29574 {
29575
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 177 times.
186 if(QMisc.shop[tmpscr[tmp].catchall].hasitem[i] != 0)
29576 {
29577 177 ++count;
29578 177 }
29579 186 }
29580
29581
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 62 times.
301 for(int32_t i=0; i<items.Count(); i++)
29582 {
29583
4/4
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 115 times.
239 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
29584 115 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
29585 239 }
29586
29587 62 break;
29588 154 }
29589
29590
2/2
✓ Branch 0 taken 771 times.
✓ Branch 1 taken 6208 times.
6979 if(pickup&ipONETIME) // set mITEM for one-time-only items
29591 {
29592 771 setmapflag(mITEM);
29593
29594 //Okay so having old source files is a godsend. You wanna know why?
29595 //Because the issue here was never to so with the wrong flag being set; no it's always been setting the right flag.
29596 //The problem here is that guy rooms were always checking for getmapflag, which used to have an internal check for the default.
29597 //The default would be mITEM if currscr was under 128 (AKA not in a cave), and mSPECIALITEM if in a cave.
29598 //However, now the check just always defaults to mSPECIALITEM, which causes this bug.
29599 //This means that this section of code is no longer a bunch of eggshells, cause none of these overcomplicated compats actually solved shit lmao - Dimi
29600
29601 /*
29602 // WARNING - Item pickups are very volatile due to crazy compatability hacks, eg., supporting
29603 // broken behavior from early ZC versions. If you change things here please comment on it's purpose.
29604
29605 // some old quests need picking up a screen item to also disable the BELOW flag (for hunger rooms, etc)
29606 // What is etc?! We need to check for every valid state here. ~Gleeok
29607 if(get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW))
29608 {
29609 // Most older quests need one-time-pickups to not remove special items, etc.
29610 if(tmpscr->room==rGRUMBLE)
29611 {
29612 setmapflag(mSPECIALITEM);
29613 }
29614 }
29615 */
29616 771 }
29617
2/2
✓ Branch 0 taken 5944 times.
✓ Branch 1 taken 264 times.
6208 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
29618
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 74 times.
264 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
29619
29620
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6978 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
6979 if(exstate > -1 && exstate < 32)
29621 {
29622 1 setxmapflag(1<<exstate);
29623 1 }
29624
29625
2/2
✓ Branch 0 taken 6978 times.
✓ Branch 1 taken 1 times.
6979 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
29626 {
29627
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
29628 1 hidden_entrance(0, true, false, -5);
29629 1 }
29630
29631 6979 collectitem_script(id2);
29632 6979 getitem(id2, false, true);
29633 }
29634
29635
2/2
✓ Branch 0 taken 542 times.
✓ Branch 1 taken 6439 times.
6981 if(pickup&ipHOLDUP)
29636 {
29637 542 attackclk=0;
29638 542 reset_swordcharge();
29639
29640
3/4
✓ Branch 0 taken 534 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 534 times.
542 if(action!=swimming && !IsSideSwim())
29641 534 reset_hookshot();
29642
29643
2/2
✓ Branch 0 taken 373 times.
✓ Branch 1 taken 165 times.
542 if(msg_onscreen)
29644 {
29645 165 dismissmsg();
29646 165 }
29647
29648 538 clear_bitmap(pricesdisplaybuf);
29649
29650
6/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 537 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 2 times.
539 if(get_bit(quest_rules, qr_OLDPICKUP) || ((tmpscr[tmp].room==rSP_ITEM || tmpscr[tmp].room==rRP_HC || tmpscr[tmp].room==rTAKEONE) && (pickup&ipONETIME2)) ||
29651
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2 (get_bit(quest_rules, qr_SHOP_ITEMS_VANISH) && (tmpscr[tmp].room==rBOTTLESHOP || tmpscr[tmp].room==rSHOP) && (pickup&ipCHECK)))
29652 {
29653 539 fadeclk=66;
29654 539 }
29655
29656
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 538 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
540 if(id2!=iBombs || action==swimming || get_bit(quest_rules,qr_BOMBHOLDFIX))
29657 {
29658 // don't hold up bombs unless swimming or the bomb hold fix quest rule is on
29659
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 532 times.
538 if(action==swimming)
29660 {
29661 6 action=waterhold1; FFCore.setHeroAction(waterhold1);
29662 6 }
29663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 else if(IsSideSwim())
29664 {
29665 action=sidewaterhold1; FFCore.setHeroAction(sidewaterhold1);
29666 }
29667 else
29668 {
29669 532 action=landhold1; FFCore.setHeroAction(landhold1);
29670 }
29671
29672
2/2
✓ Branch 0 taken 362 times.
✓ Branch 1 taken 176 times.
538 if(ptr->twohand)
29673 {
29674
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 175 times.
176 if(action==waterhold1)
29675 {
29676 1 action=waterhold2; FFCore.setHeroAction(waterhold2);
29677 1 }
29678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 175 times.
175 else if(action==sidewaterhold1)
29679 {
29680 action=sidewaterhold2; FFCore.setHeroAction(sidewaterhold2);
29681 }
29682 else
29683 {
29684 175 action=landhold2; FFCore.setHeroAction(landhold2);
29685 }
29686 176 }
29687
29688 538 holdclk=130;
29689
29690 //restart music
29691
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 77 times.
538 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0)
29692 77 music_stop();
29693
29694 538 holditem=holdid; // NES consistency: when combining blue potions, hold up the blue potion.
29695 538 freeze_guys=true;
29696 //show the info string
29697
29698
29699 //if (pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || itemsbuf[index].pickup_string_flags&itemdataPSTRING_IP_HOLDUP ) ) )
29700
29701 538 int32_t shop_pstr = 0;
29702
2/2
✓ Branch 0 taken 463 times.
✓ Branch 1 taken 75 times.
538 if (PriceIndex > -1)
29703 {
29704
2/3
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
75 switch(tmpscr[tmp].room)
29705 {
29706 case rSHOP:
29707 48 shop_pstr = QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex];
29708 48 break;
29709 case rBOTTLESHOP:
29710 shop_pstr = QMisc.bottle_shop_types[tmpscr[tmp].catchall].str[PriceIndex];
29711 break;
29712 }
29713 75 }
29714
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 538 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 538 times.
538 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
29715 {
29716 if ( (pstr > 0 && pstr < msg_count) && ( ( ( pstr_flags&itemdataPSTRING_ALWAYS || pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_IP_HOLDUP || (!(FFCore.GetItemMessagePlayed(id2))) ) ) ) )
29717 {
29718 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
29719 }
29720 else pstr = 0;
29721 if(shop_pstr)
29722 {
29723 donewmsg(shop_pstr);
29724 enqueued_str = pstr;
29725 }
29726 else if(pstr)
29727 {
29728 donewmsg(pstr);
29729 }
29730 }
29731
29732 538 }
29733
29734
3/4
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
540 if(itemsbuf[id2].family!=itype_triforcepiece || !(itemsbuf[id2].flags & ITEM_GAMEDATA))
29735 {
29736 480 sfx(tmpscr[0].holdupsfx);
29737 480 }
29738
29739 540 ptr->set_forcegrab(false);
29740 540 items.del(index);
29741
29742
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 540 times.
663 for(int32_t i=0; i<Lwpns.Count(); i++)
29743 {
29744 123 weapon *w = (weapon*)Lwpns.spr(i);
29745
29746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(w->dragging==index)
29747 {
29748 w->dragging=-1;
29749 }
29750
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 else if(w->dragging>index)
29751 {
29752 w->dragging-=1;
29753 }
29754 123 }
29755
29756 // clear up shop stuff
29757
4/4
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 272 times.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 73 times.
540 if((isdungeon()==0)&&(index!=0))
29758 {
29759
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 57 times.
73 if(boughtsomething)
29760 {
29761 57 fadeclk=66;
29762
29763
2/4
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 57 times.
57 if(((item*)items.spr(0))->id == iRupy && ((item*)items.spr(0))->pickup & ipDUMMY)
29764 {
29765 57 items.del(0);
29766
29767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 for(int32_t i=0; i<Lwpns.Count(); i++)
29768 {
29769 weapon *w = (weapon*)Lwpns.spr(i);
29770
29771 if(w->dragging==0)
29772 {
29773 w->dragging=-1;
29774 }
29775 else if(w->dragging>0)
29776 {
29777 w->dragging-=1;
29778 }
29779 }
29780 57 }
29781 57 }
29782
29783
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(msg_onscreen)
29784 {
29785 dismissmsg();
29786 }
29787
29788 73 clear_bitmap(pricesdisplaybuf);
29789 73 set_clip_state(pricesdisplaybuf, 1);
29790 73 }
29791
29792 // items.del(index);
29793 540 }
29794 else
29795 {
29796 6439 ptr->set_forcegrab(false);
29797 6439 items.del(index);
29798
29799
2/2
✓ Branch 0 taken 5459 times.
✓ Branch 1 taken 6439 times.
11898 for(int32_t i=0; i<Lwpns.Count(); i++)
29800 {
29801 5459 weapon *w = (weapon*)Lwpns.spr(i);
29802
29803
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 5422 times.
5459 if(w->dragging==index)
29804 {
29805 37 w->dragging=-1;
29806 37 }
29807
1/2
✓ Branch 0 taken 5422 times.
✗ Branch 1 not taken.
5422 else if(w->dragging>index)
29808 {
29809 w->dragging-=1;
29810 }
29811 5459 }
29812
29813
2/2
✓ Branch 0 taken 6430 times.
✓ Branch 1 taken 9 times.
6439 if(msg_onscreen)
29814 {
29815 9 dismissmsg();
29816 9 }
29817
29818 //general item pickup message
29819 //show the info string
29820 //non-held
29821 //if ( pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(index))) ) ) )
29822
3/6
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 6307 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6439 int32_t shop_pstr = ( tmpscr[tmp].room == rSHOP && PriceIndex>=0 && QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] > 0 ) ? QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] : 0;
29823
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6438 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6438 times.
6439 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
29824 {
29825
6/12
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
1 if ( (pstr > 0 && pstr < msg_count) && ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
29826 {
29827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
29828 1 }
29829 else pstr = 0;
29830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(shop_pstr)
29831 {
29832 donewmsg(shop_pstr);
29833 enqueued_str = pstr;
29834 }
29835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(pstr)
29836 {
29837 1 donewmsg(pstr);
29838 1 }
29839 1 }
29840
29841
29842 6439 clear_bitmap(pricesdisplaybuf);
29843 6439 set_clip_state(pricesdisplaybuf, 1);
29844 }
29845
29846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
6986 if(itemsbuf[id2].family==itype_triforcepiece
29847
4/4
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 6912 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 60 times.
6979 && itemsbuf[id2].misc2 <= 0 && ptr->linked_parent == eeGANON)
29848 {
29849 7 game->lvlitems[dlevel]|=liBOSS;
29850 7 }
29851 6979 handle_triforce(id2);
29852
2/2
✓ Branch 0 taken 478 times.
✓ Branch 1 taken 6501 times.
6979 if(!holdclk)
29853 6501 post_item_collect();
29854 6410695 }
29855
29856 186 void HeroClass::StartRefill(int32_t refillWhat)
29857 {
29858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186 times.
186 if(!refilling)
29859 {
29860 186 refillclk=21;
29861 186 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
29862 186 sfx(WAV_REFILL,128,true);
29863 186 refilling=refillWhat;
29864
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 6 times.
186 if(FFCore.quest_format[vZelda] < 0x255)
29865 {
29866 //Yes, this isn't a QR check. This was implemented before the QRs got bumped up.
29867 //I attempted to change this check to a quest rule, but here's the issue: this affects
29868 //triforces and potions as well, not just fairy flags. This means that having a compat rule
29869 //would result in a rule that is checked by default for every tileset or quest made before
29870 //2.55, one in a place most people won't check. That means that if they were to go to use
29871 //the new potion or triforce flags for jinx curing behavior, they'd find that it doesn't work,
29872 //all because of an obscure compat rule being checked. Most peoples instincts are sadly not
29873 //"go through the compat rules and turn them all off", so this remains a version check instead
29874 //of a qr check. Don't make my mistake and waste time trying to change this in vain. -Deedee
29875 180 Start250Refill(refillWhat);
29876 180 }
29877 else //use 2.55+ behavior
29878 {
29879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(refill_why>=0) // Item index
29880 {
29881 if(itemsbuf[refill_why].family==itype_potion)
29882 {
29883 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
29884 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
29885 }
29886 else if(itemsbuf[refill_why].family==itype_triforcepiece)
29887 {
29888 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
29889 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
29890 }
29891 }
29892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(refill_why==REFILL_FAIRY)
29893 {
29894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(!get_bit(quest_rules,qr_NONBUBBLEFAIRIES)){swordclk=0;verifyAWpn();}
29895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(get_bit(quest_rules,qr_ITEMBUBBLE))itemclk=0;
29896 6 }
29897 }
29898 186 }
29899 186 }
29900
29901 180 void HeroClass::Start250Refill(int32_t refillWhat)
29902 {
29903
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!refilling)
29904 {
29905 refillclk=21;
29906 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
29907 sfx(WAV_REFILL,128,true);
29908 refilling=refillWhat;
29909
29910 if(refill_why>=0) // Item index
29911 {
29912 if((itemsbuf[refill_why].family==itype_potion)&&(!get_bit(quest_rules,qr_NONBUBBLEMEDICINE)))
29913 {
29914 swordclk=0;
29915 verifyAWpn();
29916 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
29917 }
29918
29919 if((itemsbuf[refill_why].family==itype_triforcepiece)&&(!get_bit(quest_rules,qr_NONBUBBLETRIFORCE)))
29920 {
29921 swordclk=0;
29922 verifyAWpn();
29923 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
29924 }
29925 }
29926 else if((refill_why==REFILL_FAIRY)&&(!get_bit(quest_rules,qr_NONBUBBLEFAIRIES)))
29927 {
29928 swordclk=0;
29929 verifyAWpn();
29930 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
29931 }
29932 }
29933 180 }
29934
29935 224110 bool HeroClass::refill()
29936 {
29937
4/4
✓ Branch 0 taken 17074 times.
✓ Branch 1 taken 207036 times.
✓ Branch 2 taken 636 times.
✓ Branch 3 taken 16438 times.
224110 if(refilling==REFILL_NONE || refilling==REFILL_FAIRYDONE)
29938 {
29939 207672 return false;
29940 }
29941
29942 16438 ++refillclk;
29943 16438 int32_t speed = get_bit(quest_rules,qr_FASTFILL) ? 6 : 22;
29944 16438 int32_t refill_heart_stop=game->get_maxlife();
29945 16438 int32_t refill_magic_stop=game->get_maxmagic();
29946
29947
4/4
✓ Branch 0 taken 8317 times.
✓ Branch 1 taken 8121 times.
✓ Branch 2 taken 3362 times.
✓ Branch 3 taken 4955 times.
16438 if(refill_why>=0 && itemsbuf[refill_why].family==itype_potion)
29948 {
29949
2/6
✓ Branch 0 taken 4955 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4955 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4955 refill_heart_stop=zc_min(potion_life+(itemsbuf[refill_why].flags & ITEM_FLAG1 ?int32_t(game->get_maxlife()*(itemsbuf[refill_why].misc1 /100.0)):((itemsbuf[refill_why].misc1 *game->get_hp_per_heart()))),game->get_maxlife());
29950
2/6
✓ Branch 0 taken 4955 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4955 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4955 refill_magic_stop=zc_min(potion_magic+(itemsbuf[refill_why].flags & ITEM_FLAG2 ?int32_t(game->get_maxmagic()*(itemsbuf[refill_why].misc2 /100.0)):((itemsbuf[refill_why].misc2 *game->get_mp_per_block()))),game->get_maxmagic());
29951 4955 }
29952
29953
2/2
✓ Branch 0 taken 14731 times.
✓ Branch 1 taken 1707 times.
16438 if(refillclk%speed == 0)
29954 {
29955 // game->life&=0xFFC;
29956
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 852 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 855 times.
1707 switch(refill_what)
29957 {
29958 case REFILL_LIFE:
29959
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 813 times.
852 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
29960
29961
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 749 times.
852 if(game->get_life()>=refill_heart_stop)
29962 {
29963 103 game->set_life(refill_heart_stop);
29964 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
29965
2/2
✓ Branch 0 taken 26368 times.
✓ Branch 1 taken 103 times.
26471 for ( int32_t q = 0; q < WAV_COUNT; q++ )
29966 {
29967
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 26265 times.
26368 if ( q == (int32_t)tmpscr->oceansfx ) continue;
29968
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 26264 times.
26265 if ( q == (int32_t)tmpscr->bosssfx ) continue;
29969 26264 stop_sfx(q);
29970 26264 }
29971 103 sfx(QMisc.miscsfx[sfxREFILL]);
29972 103 refilling=REFILL_NONE;
29973 103 return false;
29974 }
29975
29976 749 break;
29977
29978 case REFILL_MAGIC:
29979 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
29980
29981 if(game->get_magic()>=refill_magic_stop)
29982 {
29983 game->set_magic(refill_magic_stop);
29984 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
29985 for ( int32_t q = 0; q < WAV_COUNT; q++ )
29986 {
29987 if ( q == (int32_t)tmpscr->oceansfx ) continue;
29988 if ( q == (int32_t)tmpscr->bosssfx ) continue;
29989 stop_sfx(q);
29990 }
29991 sfx(QMisc.miscsfx[sfxREFILL]);
29992 refilling=REFILL_NONE;
29993 return false;
29994 }
29995
29996 break;
29997
29998 case REFILL_ALL:
29999
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 788 times.
855 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
30000
2/2
✓ Branch 0 taken 825 times.
✓ Branch 1 taken 30 times.
855 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
30001
30002
4/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 753 times.
✓ Branch 2 taken 83 times.
✓ Branch 3 taken 19 times.
855 if((game->get_life()>=refill_heart_stop)&&(game->get_magic()>=refill_magic_stop))
30003 {
30004 83 game->set_life(refill_heart_stop);
30005 83 game->set_magic(refill_magic_stop);
30006 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
30007
2/2
✓ Branch 0 taken 21248 times.
✓ Branch 1 taken 83 times.
21331 for ( int32_t q = 0; q < WAV_COUNT; q++ )
30008 {
30009
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 21165 times.
21248 if ( q == (int32_t)tmpscr->oceansfx ) continue;
30010
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 21146 times.
21165 if ( q == (int32_t)tmpscr->bosssfx ) continue;
30011 21146 stop_sfx(q);
30012 21146 }
30013 83 sfx(QMisc.miscsfx[sfxREFILL]);
30014 83 refilling=REFILL_NONE;
30015 83 return false;
30016 }
30017
30018 772 break;
30019 }
30020 1521 }
30021
30022 16252 return true;
30023 224110 }
30024
30025 60 void HeroClass::getTriforce(int32_t id2)
30026 {
30027
30028 PALETTE flash_pal;
30029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 int32_t refill_frame = ( (itemsbuf[id2].misc5 > 0) ? itemsbuf[id2].misc5 : 88 );
30030
30031
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 60 times.
15420 for(int32_t i=0; i<256; i++)
30032 {
30033
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 7168 times.
15360 flash_pal[i] = get_bit(quest_rules,qr_FADE) ? _RGB(63,63,0) : _RGB(63,63,63);
30034 15360 }
30035
30036
30037
30038 //get rid off all sprites but Hero
30039 60 guys.clear();
30040 60 items.clear();
30041 60 Ewpns.clear();
30042 60 Lwpns.clear();
30043 60 Sitems.clear();
30044 60 chainlinks.clear();
30045
30046 //decorations.clear();
30047
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 17 times.
60 if(!COOLSCROLL)
30048 {
30049 17 show_subscreen_items=false;
30050 17 }
30051
30052 60 sfx(itemsbuf[id2].playsound);
30053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) music_stop();
30054
30055 //If item flag six is enabled, and a sound is set to attributes[2], play that sound.
30056
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if ( (itemsbuf[id2].flags & ITEM_FLAG14) )
30057 {
30058 uint8_t playwav = itemsbuf[id2].misc3;
30059 //zprint2("playwav is: %d\n", playwav);
30060 sfx(playwav);
30061
30062 }
30063
30064 //itemsbuf[id2].flags & ITEM_FLAG9 : Don't dismiss Messages
30065 //itemsbuf[id2].flags & ITEM_FLAG10 : Cutscene interrupts action script..
30066 //itemsbuf[id2].flags & ITEM_FLAG11 : Don't change music.
30067 //itemsbuf[id2].flags & ITEM_FLAG12 : Run Collect Script Script On Collection
30068 //itemsbuf[id2].flags & ITEM_FLAG13 : Run Action Script On Collection
30069 //itemsbuf[id2].flags & ITEM_FLAG14 : Play second sound (WAV) from Attributes[2] (misc2)
30070 //itemsbuf[id2].flags & ITEM_FLAG15 : No MIDI
30071
30072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(!(itemsbuf[id2].flags & ITEM_FLAG15)) //No MIDI flag
30073 {
30074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(itemsbuf[id2].misc1)
30075 jukebox(itemsbuf[id2].misc1+ZC_MIDI_COUNT-1);
30076 else
30077 60 try_zcmusic((char*)moduledata.base_NSF_file,moduledata.tf_track, ZC_MIDI_TRIFORCE);
30078 60 }
30079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
30080 {
30081 60 game->lvlitems[dlevel]|=liTRIFORCE;
30082 60 }
30083
30084 60 int32_t f=0;
30085 60 int32_t x2=0;
30086 60 int32_t curtain_x=0;
30087 60 int32_t c=0;
30088 /*if ( (itemsbuf[id2].flags & ITEM_FLAG12) ) //Run collect script This happens w/o the flag.
30089 {
30090 if(itemsbuf[id2].collect_script && !item_collect_doscript[id2])
30091 {
30092 //clear the item script stack for a new script
30093 ri = &(itemCollectScriptData[id2]);
30094 for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id2][q] = 0xFFFF;
30095 ri->Clear();
30096 //itemCollectScriptData[(id2 & 0xFFF)].Clear();
30097 //for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[(id2 & 0xFFF)][q] = 0;
30098 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, ((id2 & 0xFFF)*-1));
30099 if ( id2 > 0 && !item_collect_doscript[id2] ) //No collect script on item 0.
30100 {
30101 item_collect_doscript[id2] = 1;
30102 itemscriptInitialised[id2] = 0;
30103 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, ((id2)*-1));
30104 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
30105 FFCore.deallocateAllArrays(SCRIPT_ITEM,-(id2));
30106 }
30107 else if (!id2 && !item_collect_doscript[id2]) //item 0
30108 {
30109 item_collect_doscript[id2] = 1;
30110 itemscriptInitialised[id2] = 0;
30111 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, COLLECT_SCRIPT_ITEM_ZERO);
30112 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
30113 FFCore.deallocateAllArrays(SCRIPT_ITEM,COLLECT_SCRIPT_ITEM_ZERO);
30114 }
30115 }
30116 }
30117 */
30118 60 do
30119 {
30120
30121
30122
1/2
✓ Branch 0 taken 32050 times.
✗ Branch 1 not taken.
32050 if ( (itemsbuf[id2].flags & ITEM_FLAG13) ) //Run action script on collection.
30123 {
30124 if ( itemsbuf[id2].script )
30125 {
30126 if ( !item_doscript[id2] )
30127 {
30128 ri = &(itemScriptData[id2]);
30129 for ( int32_t q = 0; q < 1024; q++ ) item_stack[id2][q] = 0xFFFF;
30130 ri->Clear();
30131 item_doscript[id2] = 1;
30132 itemscriptInitialised[id2] = 0;
30133 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].script, id2);
30134 FFCore.deallocateAllArrays(SCRIPT_ITEM,(id2));
30135 }
30136 else
30137 {
30138 if ( !(itemsbuf[id2].flags & ITEM_FLAG10) ) //Cutscene halts the script it resumes after cutscene.
30139 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].script, id2); //if flag is off, run the script every frame of the cutscene.
30140 }
30141 }
30142 }
30143 //if ( itemsbuf[id2].misc2 == 2 ) //No cutscene; what if people used '2' on older quests?
30144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32050 times.
32050 if ( (itemsbuf[id2].flags & ITEM_FLAG12) ) //No cutscene
30145 {
30146 return;
30147 }
30148
2/2
✓ Branch 0 taken 31990 times.
✓ Branch 1 taken 60 times.
32050 if(f==40)
30149 {
30150 60 actiontype oldaction = action;
30151 60 ALLOFF((!(itemsbuf[id2].flags & ITEM_FLAG9)), false);
30152 60 action=oldaction; // have to reset this flag
30153 60 FFCore.setHeroAction(oldaction);
30154 60 }
30155
30156
30157
4/4
✓ Branch 0 taken 29650 times.
✓ Branch 1 taken 2400 times.
✓ Branch 2 taken 26770 times.
✓ Branch 3 taken 2880 times.
32050 if(f>=40 && f<88)
30158 {
30159
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 1344 times.
2880 if(get_bit(quest_rules,qr_FADE))
30160 {
30161
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1536 if (!flash_reduction_enabled() && (f&7) == 0)
30162 {
30163 fade_interpolate(RAMpal,flash_pal,RAMpal,42,0,CSET(6)-1);
30164 refreshpal=true;
30165 }
30166
30167
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 384 times.
1536 if((f&3)==2)
30168 {
30169 384 loadpalset(0,0);
30170 384 loadpalset(1,1);
30171 384 loadpalset(5,5);
30172
30173
2/2
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 12 times.
384 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
30174 12 else loadlvlpal(0xB); // TODO: Cave/Item Cellar distinction?
30175 384 }
30176 1536 }
30177 else
30178 {
30179
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1344 if(!flash_reduction_enabled() && (f&7) == 0)
30180 {
30181 for(int32_t cs2=2; cs2<5; cs2++)
30182 {
30183 for(int32_t i=1; i<16; i++)
30184 {
30185 RAMpal[CSET(cs2)+i]=flash_pal[CSET(cs2)+i];
30186 }
30187 }
30188
30189 refreshpal=true;
30190 }
30191
30192
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 168 times.
1344 if((f&7)==4)
30193 {
30194
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
30195 else loadlvlpal(0xB);
30196
30197 168 loadpalset(5,5);
30198 168 }
30199 }
30200 2880 }
30201
30202
30203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32050 times.
32050 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
30204 {
30205
2/2
✓ Branch 0 taken 31990 times.
✓ Branch 1 taken 60 times.
32050 if(f==refill_frame)
30206 {
30207 60 refill_what=REFILL_ALL;
30208 60 refill_why=id2;
30209 60 StartRefill(REFILL_ALL);
30210 60 refill();
30211 60 }
30212
30213
2/2
✓ Branch 0 taken 28740 times.
✓ Branch 1 taken 3310 times.
32050 if(f==(refill_frame+1))
30214 {
30215
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 3250 times.
3310 if(refill())
30216 {
30217 3250 --f;
30218 3250 }
30219 3310 }
30220 32050 }
30221
30222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32050 times.
32050 if(itemsbuf[id2].flags & ITEM_FLAG1) // Warp out flag
30223 {
30224
4/4
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 15730 times.
✓ Branch 2 taken 11520 times.
✓ Branch 3 taken 4800 times.
32050 if(f>=208 && f<288)
30225 {
30226 4800 ++x2;
30227
30228
3/3
✓ Branch 0 taken 1920 times.
✓ Branch 1 taken 1920 times.
✓ Branch 2 taken 960 times.
4800 switch(++c)
30229 {
30230 case 5:
30231 960 c=0;
30232 [[fallthrough]];
30233 case 0:
30234 case 2:
30235 case 3:
30236 2880 ++x2;
30237 2880 break;
30238 }
30239 4800 }
30240
30241 32050 do_dcounters();
30242
30243
2/2
✓ Branch 0 taken 11520 times.
✓ Branch 1 taken 20530 times.
32050 if(f<288)
30244 {
30245 20530 curtain_x=x2&0xF8;
30246 20530 draw_screen_clip_rect_x1=curtain_x;
30247 20530 draw_screen_clip_rect_x2=255-curtain_x;
30248 20530 draw_screen_clip_rect_y1=0;
30249 20530 draw_screen_clip_rect_y2=223;
30250 //draw_screen(tmpscr);
30251 20530 }
30252 32050 }
30253
30254 32050 draw_screen(tmpscr);
30255 //this causes bugs
30256 //the subscreen appearing over the curtain effect should now be fixed in draw_screen
30257 //so this is not necessary -DD
30258 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,false);
30259
30260 //Run Triforce Script
30261 32050 advanceframe(true);
30262 32050 ++f;
30263
2/2
✓ Branch 0 taken 31990 times.
✓ Branch 1 taken 60 times.
64100 }
30264 while
30265 (
30266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32050 times.
32050 (f < ( (itemsbuf[id2].misc4 > 0) ? itemsbuf[id2].misc4 : 408))
30267
4/6
✓ Branch 0 taken 4380 times.
✓ Branch 1 taken 27670 times.
✓ Branch 2 taken 4380 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4380 times.
32050 || (!(itemsbuf[id2].flags & ITEM_FLAG15) /*&& !(itemsbuf[id2].flags & ITEM_FLAG11)*/ && (midi_pos > 0 && !replay_is_active()))
30268
4/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4380 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4380 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4234 times.
✓ Branch 7 taken 146 times.
8760 || (/*!(itemsbuf[id2].flags & ITEM_FLAG15) &&*/ !(itemsbuf[id2].flags & ITEM_FLAG11) && (zcmusic!=NULL) && (zcmusic->position<800 && !replay_is_active())
30269 // Music is played at the same speed when fps is uncapped, so in replay mode we need to ignore the music position and instead
30270 // just count frames. 480 is the number of frames it takes for the triforce song in classic_1st.qst to finish playing, but the exact
30271 // value doesn't matter.
30272
2/4
✓ Branch 0 taken 4234 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4380 times.
4380 || (replay_is_active() && f < 480) )
30273 ); // 800 may not be just right, but it works
30274
30275 60 action=none; FFCore.setHeroAction(none);
30276 60 holdclk=0;
30277 60 draw_screen_clip_rect_x1=0;
30278 60 draw_screen_clip_rect_x2=255;
30279 60 draw_screen_clip_rect_y1=0;
30280 60 draw_screen_clip_rect_y2=223;
30281 60 show_subscreen_items=true;
30282
30283 //Warp Hero out of item cellars, in 2.10 and earlier quests. -Z ( 16th January, 2019 )
30284 //Added a QR for this, to Other->2, as `Triforce in Cellar Warps Hero Out`. -Z 15th March, 2019
30285
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 26 times.
✓ Branch 5 taken 1 times.
60 if((itemsbuf[id2].flags & ITEM_FLAG1) && ( get_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR) ? ( currscr < MAPSCRS192b136 ) : (currscr < MAPSCRSNORMAL) ) )
30286 {
30287 61 sdir=dir;
30288 61 dowarp(1,0); //side warp
30289 61 }
30290 else
30291 {
30292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) playLevelMusic();
30293 }
30294 60 }
30295
30296 4662 void red_shift()
30297 {
30298 4662 int32_t tnum=176;
30299
30300 // set up the new palette
30301
2/2
✓ Branch 0 taken 149184 times.
✓ Branch 1 taken 4662 times.
153846 for(int32_t i=CSET(2); i < CSET(4); i++)
30302 {
30303 149184 int32_t r = (i-CSET(2)) << 1;
30304 149184 RAMpal[i+tnum].r = r;
30305 149184 RAMpal[i+tnum].g = r >> 3;
30306 149184 RAMpal[i+tnum].b = r >> 4;
30307 149184 }
30308
30309 // color scale the game screen
30310
2/2
✓ Branch 0 taken 783216 times.
✓ Branch 1 taken 4662 times.
787878 for(int32_t y=0; y<168; y++)
30311 {
30312
2/2
✓ Branch 0 taken 200503296 times.
✓ Branch 1 taken 783216 times.
201286512 for(int32_t x=0; x<256; x++)
30313 {
30314 200503296 int32_t c = framebuf->line[y+playing_field_offset][x];
30315
2/2
✓ Branch 0 taken 172617996 times.
✓ Branch 1 taken 27885300 times.
200503296 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
30316
1/2
✓ Branch 0 taken 200503296 times.
✗ Branch 1 not taken.
200503296 framebuf->line[y+playing_field_offset][x] = (c ? (r+tnum+CSET(2)) : 0);
30317 200503296 }
30318 783216 }
30319
30320 4662 refreshpal = true;
30321 4662 }
30322
30323
30324
30325 void setup_red_screen_old()
30326 {
30327 clear_bitmap(framebuf);
30328 rectfill(scrollbuf, 0, 0, 255, 167, 0);
30329
30330 if(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, tmpscr, 0, playing_field_offset, 2);
30331
30332 if(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, tmpscr, 0, playing_field_offset, 2);
30333
30334 putscr(scrollbuf, 0, 0, tmpscr);
30335 putscrdoors(scrollbuf,0,0,tmpscr);
30336 blit(scrollbuf, framebuf, 0, 0, 0, playing_field_offset, 256, 168);
30337 do_layer(framebuf, 0, 1, tmpscr, 0, 0, 2);
30338
30339 if(!(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, tmpscr, 0, 0, 2);
30340
30341 do_layer(framebuf, -2, 0, tmpscr, 0, 0, 2);
30342 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
30343 {
30344 do_layer(framebuf, -2, 1, tmpscr, 0, 0, 2);
30345 do_layer(framebuf, -2, 2, tmpscr, 0, 0, 2);
30346 }
30347
30348 if(!(msg_bg_display_buf->clip))
30349 {
30350 blit_msgstr_bg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
30351 }
30352
30353 if(!(msg_portrait_display_buf->clip))
30354 {
30355 blit_msgstr_prt(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
30356 }
30357
30358 if(!(msg_txt_display_buf->clip))
30359 {
30360 blit_msgstr_fg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
30361 }
30362
30363 if(!(pricesdisplaybuf->clip))
30364 {
30365 masked_blit(pricesdisplaybuf, framebuf,0,0,0,playing_field_offset, 256,168);
30366 }
30367
30368 //red shift
30369 // color scale the game screen
30370 for(int32_t y=0; y<168; y++)
30371 {
30372 for(int32_t x=0; x<256; x++)
30373 {
30374 int32_t c = framebuf->line[y+playing_field_offset][x];
30375 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
30376 framebuf->line[y+playing_field_offset][x] = (c ? (r+CSET(2)) : 0);
30377 }
30378 }
30379
30380 // Hero->draw(framebuf);
30381 blit(framebuf,scrollbuf, 0, playing_field_offset, 256, playing_field_offset, 256, 168);
30382
30383 clear_bitmap(framebuf);
30384
30385 if(!((tmpscr->layermap[2]==0||(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)))
30386 && tmpscr->layermap[3]==0
30387 && tmpscr->layermap[4]==0
30388 && tmpscr->layermap[5]==0
30389 && !overheadcombos(tmpscr)))
30390 {
30391 if(!(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, tmpscr, 0, 0, 2);
30392
30393 do_layer(framebuf, 0, 4, tmpscr, 0, 0, 2);
30394 do_layer(framebuf, -1, 0, tmpscr, 0, 0, 2);
30395 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
30396 {
30397 do_layer(framebuf, -1, 1, tmpscr, 0, 0, 2);
30398 do_layer(framebuf, -1, 2, tmpscr, 0, 0, 2);
30399 }
30400 do_layer(framebuf, 0, 5, tmpscr, 0, 0, 2);
30401 do_layer(framebuf, 0, 6, tmpscr, 0, 0, 2);
30402
30403 //do an AND masked blit for messages on top of layers
30404 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(pricesdisplaybuf->clip) || !(msg_portrait_display_buf->clip))
30405 {
30406 BITMAP* subbmp = create_bitmap_ex(8,256,168);
30407 clear_bitmap(subbmp);
30408 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(msg_portrait_display_buf->clip))
30409 {
30410 masked_blit(framebuf, subbmp, 0, playing_field_offset, 0, 0, 256, 168);
30411 if(!(msg_bg_display_buf->clip)) blit_msgstr_bg(subbmp, 0, 0, 0, 0, 256, 168);
30412 if(!(msg_portrait_display_buf->clip)) blit_msgstr_prt(subbmp, 0, 0, 0, 0, 256, 168);
30413 if(!(msg_txt_display_buf->clip)) blit_msgstr_fg(subbmp, 0, 0, 0, 0, 256, 168);
30414 }
30415 for(int32_t y=0; y<168; y++)
30416 {
30417 for(int32_t x=0; x<256; x++)
30418 {
30419 int32_t c1 = framebuf->line[y+playing_field_offset][x];
30420 int32_t c2 = subbmp->line[y][x];
30421 int32_t c3 = pricesdisplaybuf->clip ? 0 : pricesdisplaybuf->line[y][x];
30422
30423 if(c1 && c3)
30424 {
30425 framebuf->line[y+playing_field_offset][x] = c3;
30426 }
30427 else if(c1 && c2)
30428 {
30429 framebuf->line[y+playing_field_offset][x] = c2;
30430 }
30431 }
30432 }
30433 destroy_bitmap(subbmp);
30434 }
30435
30436 //red shift
30437 // color scale the game screen
30438 for(int32_t y=0; y<168; y++)
30439 {
30440 for(int32_t x=0; x<256; x++)
30441 {
30442 int32_t c = framebuf->line[y+playing_field_offset][x];
30443 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
30444 framebuf->line[y+playing_field_offset][x] = r+CSET(2);
30445 }
30446 }
30447 }
30448
30449 blit(framebuf,scrollbuf, 0, playing_field_offset, 0, playing_field_offset, 256, 168);
30450
30451 // set up the new palette
30452 for(int32_t i=CSET(2); i < CSET(4); i++)
30453 {
30454 int32_t r = (i-CSET(2)) << 1;
30455 RAMpal[i].r = r;
30456 RAMpal[i].g = r >> 3;
30457 RAMpal[i].b = r >> 4;
30458 }
30459
30460 refreshpal = true;
30461 }
30462
30463
30464
30465 60 void slide_in_color(int32_t color)
30466 {
30467
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 60 times.
360 for(int32_t i=1; i<16; i+=3)
30468 {
30469 300 RAMpal[CSET(2)+i+2] = RAMpal[CSET(2)+i+1];
30470 300 RAMpal[CSET(2)+i+1] = RAMpal[CSET(2)+i];
30471 300 RAMpal[CSET(2)+i] = NESpal(color);
30472 300 }
30473
30474 60 refreshpal=true;
30475 60 }
30476
30477
30478 54 void HeroClass::heroDeathAnimation()
30479 {
30480 54 int32_t f=0;
30481 54 int32_t deathclk=0,deathfrm=0;
30482
30483 54 action=none; FFCore.setHeroAction(dying); //mayhaps a new action of 'gameover'? -Z
30484
30485 54 kill_sfx(); //call before the onDeath script.
30486
30487 //do
30488 //{
30489
30490 // ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH, SCRIPT_PLAYER_DEATH);
30491 // FFCore.Waitframe();
30492 //}while(player_doscript);
30493 //ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH, SCRIPT_PLAYER_DEATH);
30494 //while(player_doscript) { advanceframe(true); } //Not safe. The script runs for only one frame at present.
30495
30496 //Playing=false;
30497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if(!debug_enabled)
30498 {
30499 54 Paused=false;
30500 54 }
30501
30502 /*
30503 game->set_deaths(zc_min(game->get_deaths()+1,999));
30504 dir=down;
30505 music_stop();
30506
30507 attackclk=hclk=superman=0;
30508 scriptcoldet = 1;
30509
30510 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
30511
30512
30513
30514 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
30515 quakeclk=wavy=0;
30516
30517 //in original Z1, Hero marker vanishes at death.
30518 //code in subscr.cpp, put_passive_subscr checks the following value.
30519 //color 255 is a GUI color, so quest makers shouldn't be using this value.
30520 //Also, subscreen is static after death in Z1.
30521 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
30522 QMisc.colors.hero_dot = 255;
30523 //doesn't work
30524 //scrollbuf is tampered with by draw_screen()
30525 //put_passive_subscr(scrollbuf, &QMisc, 256, passive_subscreen_offset, false, false);//save this and reuse it.
30526 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
30527 clear_bitmap(subscrbmp);
30528 put_passive_subscr(subscrbmp, &QMisc, 0, passive_subscreen_offset, false, sspUP);
30529 QMisc.colors.hero_dot = tmp_hero_dot;
30530 */
30531 54 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
30532 54 clear_bitmap(subscrbmp);
30533 //get rid off all sprites but Hero
30534 54 guys.clear();
30535 54 items.clear();
30536 54 Ewpns.clear();
30537 54 Lwpns.clear();
30538 54 Sitems.clear();
30539 54 chainlinks.clear();
30540 54 decorations.clear();
30541 54 Playing = false;
30542
30543
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 game->set_deaths(zc_min(game->get_deaths()+1,USHRT_MAX));
30544 54 dir=down;
30545 54 music_stop();
30546
30547 54 attackclk=hclk=superman=0;
30548 54 scriptcoldet = 1;
30549
30550
2/2
✓ Branch 0 taken 1728 times.
✓ Branch 1 taken 54 times.
1782 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
30551
30552
30553
30554 54 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
30555 54 quakeclk=wavy=0;
30556
30557 //in original Z1, Hero marker vanishes at death.
30558 //code in subscr.cpp, put_passive_subscr checks the following value.
30559 //color 255 is a GUI color, so quest makers shouldn't be using this value.
30560 //Also, subscreen is static after death in Z1.
30561 54 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
30562 54 QMisc.colors.hero_dot = 255;
30563 //doesn't work
30564 //scrollbuf is tampered with by draw_screen()
30565 //put_passive_subscr(scrollbuf, &QMisc, 256, passive_subscreen_offset, false, false);//save this and reuse it.
30566
30567 54 put_passive_subscr(subscrbmp, &QMisc, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
30568 //Don't forget passive subscreen scripts!
30569
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 1 times.
54 if(get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
30570 {
30571 1 script_drawing_commands.Clear(); //We only want draws from this script
30572
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(DMaps[currdmap].passive_sub_script != 0)
30573 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
30574
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(passive_subscreen_waitdraw && DMaps[currdmap].passive_sub_script != 0 && passive_subscreen_doscript != 0)
30575 {
30576 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
30577 passive_subscreen_waitdraw = false;
30578 }
30579 1 BITMAP* tmp = framebuf;
30580 1 framebuf = subscrbmp; //Hack; force draws to subscrbmp
30581 1 do_script_draws(framebuf, tmpscr, 0, playing_field_offset); //Draw the script draws
30582 1 framebuf = tmp;
30583 1 script_drawing_commands.Clear(); //Don't let these draws repeat during 'draw_screen()'
30584 1 }
30585 54 QMisc.colors.hero_dot = tmp_hero_dot;
30586 54 bool clearedit = false;
30587 54 do
30588 {
30589
2/2
✓ Branch 0 taken 13717 times.
✓ Branch 1 taken 5346 times.
19063 if(f<254)
30590 {
30591
2/2
✓ Branch 0 taken 11935 times.
✓ Branch 1 taken 1782 times.
13717 if(f<=32)
30592 {
30593 1782 hclk=(32-f);
30594 1782 }
30595
30596
4/4
✓ Branch 0 taken 10369 times.
✓ Branch 1 taken 3348 times.
✓ Branch 2 taken 6265 times.
✓ Branch 3 taken 4104 times.
13717 if(f>=62 && f<138)
30597 {
30598
5/5
✓ Branch 0 taken 3240 times.
✓ Branch 1 taken 216 times.
✓ Branch 2 taken 216 times.
✓ Branch 3 taken 216 times.
✓ Branch 4 taken 216 times.
4104 switch((f-62)%20)
30599 {
30600 case 0:
30601 216 dir=right;
30602 216 break;
30603
30604 case 5:
30605 216 dir=up;
30606 216 break;
30607
30608 case 10:
30609 216 dir=left;
30610 216 break;
30611
30612 case 15:
30613 216 dir=down;
30614 216 break;
30615 }
30616
30617 4104 herostep();
30618 4104 }
30619
30620
4/4
✓ Branch 0 taken 3241 times.
✓ Branch 1 taken 10476 times.
✓ Branch 2 taken 2483 times.
✓ Branch 3 taken 758 times.
13717 if(f>=194 && f<208)
30621 {
30622
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 54 times.
758 if(f==194)
30623 {
30624 54 action=dying;
30625 54 FFCore.setHeroAction(dying);
30626 54 }
30627
30628 758 extend = 0;
30629 758 cs = wpnsbuf[spr_death].csets&15;
30630 758 tile = wpnsbuf[spr_death].tile;
30631
2/2
✓ Branch 0 taken 742 times.
✓ Branch 1 taken 16 times.
758 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS))
30632 {
30633 16 tile += deathfrm;
30634 16 f = 206;
30635
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(++deathclk >= wpnsbuf[spr_death].speed)
30636 {
30637 4 deathclk=0;
30638
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 if(++deathfrm >= wpnsbuf[spr_death].frames)
30639 {
30640 1 f = 208;
30641 1 deathfrm = 0;
30642 1 }
30643 4 }
30644 16 }
30645
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 392 times.
742 else if(BSZ)
30646 {
30647 350 tile += (f-194)/3;
30648 350 }
30649
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 112 times.
392 else if(f>=204)
30650 {
30651 112 ++tile;
30652 112 }
30653 758 }
30654
30655
2/2
✓ Branch 0 taken 13663 times.
✓ Branch 1 taken 54 times.
13717 if(f==208)
30656 {
30657
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 51 times.
54 if ( dontdraw < 2 ) { dontdraw = 1; }
30658 54 }
30659
2/2
✓ Branch 0 taken 10669 times.
✓ Branch 1 taken 3048 times.
13717 if(get_bit(quest_rules,qr_FADE))
30660 {
30661
2/2
✓ Branch 0 taken 7140 times.
✓ Branch 1 taken 3529 times.
10669 if(f < 170)
30662 {
30663
2/2
✓ Branch 0 taken 4620 times.
✓ Branch 1 taken 2520 times.
7140 if(f<60)
30664 {
30665 2520 draw_screen(tmpscr);
30666 //reuse our static subscreen
30667 2520 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
30668 2520 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30669 2520 }
30670
30671
2/2
✓ Branch 0 taken 7098 times.
✓ Branch 1 taken 42 times.
7140 if(f==60)
30672 {
30673 42 red_shift();
30674 42 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
30675 42 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
30676 42 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
30677
30678
2/2
✓ Branch 0 taken 10752 times.
✓ Branch 1 taken 42 times.
10794 for(int32_t q=0; q<PAL_SIZE; q++)
30679 {
30680 10752 trans_table2.data[0][q] = q;
30681 10752 trans_table2.data[q][q] = q;
30682 10752 }
30683 42 }
30684
30685
3/4
✓ Branch 0 taken 4620 times.
✓ Branch 1 taken 2520 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4620 times.
7140 if(f>=60 && f<=169)
30686 {
30687 4620 draw_screen(tmpscr);
30688 //reuse our static subscreen
30689 4620 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30690 4620 red_shift();
30691
30692 4620 }
30693
30694
3/4
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 5838 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1302 times.
7140 if(f>=139 && f<=169)//fade from red to black
30695 {
30696 1302 fade_interpolate(RAMpal,black_palette,RAMpal, (f-138)<<1, 224, 255);
30697 1302 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
30698 1302 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
30699 1302 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
30700
30701
2/2
✓ Branch 0 taken 333312 times.
✓ Branch 1 taken 1302 times.
334614 for(int32_t q=0; q<PAL_SIZE; q++)
30702 {
30703 333312 trans_table2.data[0][q] = q;
30704 333312 trans_table2.data[q][q] = q;
30705 333312 }
30706
30707 1302 refreshpal=true;
30708 1302 }
30709 7140 }
30710 else //f>=170
30711 {
30712
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 42 times.
3529 if(f==170)//make Hero grayish
30713 {
30714 42 fade_interpolate(RAMpal,black_palette,RAMpal,64, 224, 255);
30715
30716
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 42 times.
714 for(int32_t i=CSET(6); i < CSET(7); i++)
30717 {
30718 672 int32_t g = (RAMpal[i].r + RAMpal[i].g + RAMpal[i].b)/3;
30719 672 RAMpal[i] = _RGB(g,g,g);
30720 672 }
30721
30722 42 refreshpal = true;
30723 42 }
30724
30725 //draw only hero. otherwise black layers might cover him.
30726 3529 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
30727 3529 draw(framebuf);
30728 3529 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30729 }
30730 10669 }
30731 else //!qr_FADE
30732 {
30733
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==58)
30734 {
30735
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 12 times.
1164 for(int32_t i = 0; i < 96; i++)
30736 1152 tmpscr->cset[i] = 3;
30737
30738
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 for(int32_t j=0; j<6; j++)
30739
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 70 times.
74 if(tmpscr->layermap[j]>0)
30740
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 2 times.
194 for(int32_t i=0; i<96; i++)
30741 194 tmpscr2[j].cset[i] = 3;
30742 12 }
30743
30744
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==59)
30745 {
30746
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 12 times.
972 for(int32_t i = 96; i < 176; i++)
30747 960 tmpscr->cset[i] = 3;
30748
30749
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 for(int32_t j=0; j<6; j++)
30750
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 70 times.
74 if(tmpscr->layermap[j]>0)
30751
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 2 times.
162 for(int32_t i=96; i<176; i++)
30752 162 tmpscr2[j].cset[i] = 3;
30753 12 }
30754
30755
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==60)
30756 {
30757
2/2
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
2124 for(int32_t i=0; i<176; i++)
30758 {
30759 2112 tmpscr->cset[i] = 2;
30760 2112 }
30761
30762
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 for(int32_t j=0; j<6; j++)
30763
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 70 times.
74 if(tmpscr->layermap[j]>0)
30764
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 2 times.
354 for(int32_t i=0; i<176; i++)
30765 354 tmpscr2[j].cset[i] = 2;
30766
30767
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 12 times.
72 for(int32_t i=1; i<16; i+=3)
30768 {
30769 60 RAMpal[CSET(2)+i] = NESpal(0x17);
30770 60 RAMpal[CSET(2)+i+1] = NESpal(0x16);
30771 60 RAMpal[CSET(2)+i+2] = NESpal(0x26);
30772 60 }
30773
30774 12 refreshpal=true;
30775 12 }
30776
30777
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==139)
30778 12 slide_in_color(0x06);
30779
30780
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==149)
30781 12 slide_in_color(0x07);
30782
30783
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==159)
30784 12 slide_in_color(0x0F);
30785
30786
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==169)
30787 {
30788 12 slide_in_color(0x0F);
30789 12 slide_in_color(0x0F);
30790 12 }
30791
30792
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==170)
30793 {
30794
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 12 times.
72 for(int32_t i=1; i<16; i+=3)
30795 {
30796 60 RAMpal[CSET(6)+i] = NESpal(0x10);
30797 60 RAMpal[CSET(6)+i+1] = NESpal(0x30);
30798 60 RAMpal[CSET(6)+i+2] = NESpal(0x00);
30799 60 refreshpal = true;
30800 60 }
30801 12 }
30802
30803
2/2
✓ Branch 0 taken 2028 times.
✓ Branch 1 taken 1020 times.
3048 if(f < 169)
30804 {
30805 2028 draw_screen(tmpscr);
30806 //reuse our static subscreen
30807 2028 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30808 2028 }
30809 else
30810 {
30811 //draw only hero. otherwise black layers might cover him.
30812 1020 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
30813 1020 draw(framebuf);
30814 1020 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30815 }
30816 }
30817 13717 }
30818
30819
2/2
✓ Branch 0 taken 5184 times.
✓ Branch 1 taken 162 times.
5346 else if(f<350)//draw 'GAME OVER' text
30820 {
30821
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5184 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5184 if(get_bit(quest_rules, qr_INSTANT_RESPAWN) && !get_bit(quest_rules, qr_INSTANT_CONTINUE))
30822 {
30823 Quit = qRELOAD;
30824 skipcont = 1;
30825 clear_bitmap(framebuf);
30826 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30827 }
30828
2/4
✓ Branch 0 taken 5184 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5184 times.
5184 else if(!get_bit(quest_rules, qr_INSTANT_RESPAWN) && get_bit(quest_rules, qr_INSTANT_CONTINUE))
30829 {
30830 Quit = qCONT;
30831 skipcont = 1;
30832 clear_bitmap(framebuf);
30833 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30834 }
30835 else
30836 {
30837 5184 clear_a5_bmp(rti_infolayer.bitmap);
30838 5184 clear_to_color(framebuf,SaveScreenSettings[SAVESC_BACKGROUND]);
30839 5184 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30840 5184 textout_ex(framebuf,get_zc_font(font_zfont),"GAME OVER",96,playing_field_offset+80,SaveScreenSettings[SAVESC_TEXT],-1);
30841 }
30842 5184 }
30843 else
30844 {
30845 162 clear_bitmap(framebuf);
30846 }
30847
30848 //SFX... put them all here
30849
4/4
✓ Branch 0 taken 18902 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 53 times.
19063 switch(f)
30850 {
30851 case 0:
30852 54 sfx(getHurtSFX(),pan(x.getInt()));
30853 54 break;
30854 //Death sound.
30855 case 60:
30856 54 sfx(WAV_SPIRAL);
30857 54 break;
30858 //Message sound.
30859 case 194:
30860 53 sfx(WAV_MSG);
30861 53 break;
30862 }
30863 //adv:
30864 19063 advanceframe(true);
30865 19063 ++f;
30866 //if (!player_doscript ) ++f;
30867
2/2
✓ Branch 0 taken 19009 times.
✓ Branch 1 taken 54 times.
38126 }
30868
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 19009 times.
19063 while(f<353 && !Quit);
30869
30870 54 destroy_bitmap(subscrbmp);
30871 54 action=none; FFCore.setHeroAction(none);
30872
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 51 times.
54 if ( dontdraw < 2 ) { dontdraw=0; }
30873 54 }
30874
30875
30876 13 void HeroClass::ganon_intro()
30877 {
30878 /*
30879 ************************
30880 * GANON INTRO SEQUENCE *
30881 ************************
30882 -25 DOT updates
30883 -24 HERO in
30884 0 TRIFORCE overhead - code begins at this point (f == 0)
30885 47 GANON in
30886 58 LIGHT step
30887 68 LIGHT step
30888 78 LIGHT step
30889 255 TRIFORCE out
30890 256 TRIFORCE in
30891 270 TRIFORCE out
30892 271 GANON out, HERO face up
30893 */
30894 13 loaded_guys=true;
30895 13 loaditem();
30896
30897
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 9 times.
13 if(game->lvlitems[dlevel]&liBOSS)
30898 {
30899 4 return;
30900 }
30901
30902 9 dir=down;
30903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if ( !isSideViewHero() )
30904 {
30905 9 fall = 0; //Fix midair glitch on holding triforce. -Z
30906 9 fakefall = 0;
30907 9 z = 0;
30908 9 fakez = 0;
30909 9 }
30910 9 action=landhold2; FFCore.setHeroAction(landhold2);
30911 9 holditem=getItemID(itemsbuf,itype_triforcepiece, 1);
30912 //not good, as this only returns the highest level that Hero possesses. -DD
30913 //getHighestLevelOfFamily(game, itemsbuf, itype_triforcepiece, false));
30914
30915
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2169 times.
✓ Branch 2 taken 2169 times.
✓ Branch 3 taken 9 times.
2178 for(int32_t f=0; f<271 && !Quit; f++)
30916 {
30917
2/2
✓ Branch 0 taken 2160 times.
✓ Branch 1 taken 9 times.
2169 if(f==47)
30918 {
30919 9 music_stop();
30920 9 stop_sfx(WAV_ROAR);
30921 9 sfx(WAV_GASP);
30922 9 sfx(WAV_GANON);
30923 9 int32_t Id=0;
30924
30925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 711 times.
711 for(int32_t i=0; i<eMAXGUYS; i++)
30926 {
30927
2/2
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 9 times.
711 if(guysbuf[i].flags2&eneflag_ganon)
30928 {
30929 9 Id=i;
30930 9 break;
30931 }
30932 702 }
30933
30934
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
9 if(current_item(itype_ring))
30935 {
30936 8 addenemy(160,96,Id,0);
30937 8 }
30938 else
30939 {
30940 1 addenemy(80,32,Id,0);
30941 }
30942 9 }
30943
30944
2/2
✓ Branch 0 taken 2160 times.
✓ Branch 1 taken 9 times.
2169 if(f==48)
30945 {
30946 9 lighting(true,true); // Hmm. -L
30947 9 f += 30;
30948 9 }
30949
30950 //NES Z1, the triforce vanishes for one frame in two cases
30951 //while still showing Hero's two-handed overhead sprite.
30952 //This should be a Quest Rule for NES Accuracy. -Z
30953
4/4
✓ Branch 0 taken 2160 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 2151 times.
2169 if(f==255 || f==270)
30954 {
30955 18 holditem=-1;
30956 18 }
30957
30958
2/2
✓ Branch 0 taken 2160 times.
✓ Branch 1 taken 9 times.
2169 if(f==256)
30959 {
30960 9 holditem=getItemID(itemsbuf,itype_triforcepiece,1);
30961 9 }
30962
30963 2169 draw_screen(tmpscr);
30964 2169 advanceframe(true);
30965
30966
1/2
✓ Branch 0 taken 2169 times.
✗ Branch 1 not taken.
2169 if(rSbtn())
30967 {
30968 conveyclk=3;
30969 int32_t tmp_subscr_clk = frame;
30970 dosubscr(&QMisc);
30971 newscr_clk += frame - tmp_subscr_clk;
30972 }
30973
30974 2169 }
30975
30976 9 action=none; FFCore.setHeroAction(none);
30977 9 dir=up;
30978
30979
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 7 times.
9 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && (tunes[MAXMIDIS-1].data))
30980 2 jukebox(MAXMIDIS-1);
30981 else
30982 7 playLevelMusic();
30983
30984 9 currcset=DMaps[currdmap].color;
30985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (get_bit(quest_rules, qr_GANONINTRO) )
30986 {
30987 9 dointro();
30988 //Yes, I checked. This is literally in 2.10 (minus this if statement of course).
30989 //I have no clue why it's here; Literally the only difference between dointro in 2.10 and dointro in this version is an 'else' that sets introclk and intropos to 74.
30990 //I have no idea what was going through the original devs heads and I'm extremely worried I'm missing something, cause at first glance this looks like
30991 //a hack solution to an underlying bug, but no! There's just a fucking dointro() call in older versions and I don't know *why*. -Deedee
30992 9 }
30993 //dointro(); //This is likely what causes Ganon Rooms to repeat the DMap intro.
30994 //I suppose it is to allow the user to make Gaanon rooms have their own dialogue, if they are
30995 //on a different DMap.
30996 //~ Otherwise, why is it here?! -Z
30997
30998
30999 //if ( !(DMaps[currdmap].flags&dmfALWAYSMSG) ) { dointro(); } //This is likely what causes Ganon Rooms to repeat the DMap intro.
31000 //If we try it this way: The dmap flag /always display intro string/ is probably why James had this issue.
31001
31002 //The only fix that I can think of, off the top of me head, is either a QR or a Screen Flag to disable the intro text.
31003 //Users who use that dmap rule should put ganons room on its own DMap! -Z
31004 9 cont_sfx(WAV_ROAR);
31005 13 }
31006
31007 8 void HeroClass::win_game()
31008 {
31009
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 replay_step_comment("win_game");
31010 8 Playing=Paused=false;
31011 8 action=won; FFCore.setHeroAction(won);
31012 8 Quit=qWON;
31013 8 hclk=0;
31014 8 x = 136;
31015
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7 times.
8 y = (isdungeon() && currscr<128) ? 75 : 73;
31016 8 z = fakez = fall = fakefall = spins = 0;
31017 8 dir=left;
31018 8 }
31019
31020 14980 void HeroClass::reset_swordcharge()
31021 {
31022 14980 charging=spins=tapping=0;
31023 14980 }
31024
31025 47171 void HeroClass::reset_hookshot()
31026 {
31027
10/12
✓ Branch 0 taken 35598 times.
✓ Branch 1 taken 11573 times.
✓ Branch 2 taken 35591 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 35545 times.
✓ Branch 5 taken 46 times.
✓ Branch 6 taken 35540 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 35540 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 35540 times.
47171 if(action!=walking && action!=rafting && action!=landhold1 && action!=landhold2 && action!=sidewaterhold1 && action!=sidewaterhold2)
31028 {
31029 35540 action=none; FFCore.setHeroAction(none);
31030 35540 }
31031
31032 47171 hookshot_frozen=false;
31033 47171 hookshot_used=false;
31034 47171 pull_hero=false;
31035 47171 hs_fix=false;
31036 47171 switchhookclk = switchhookmaxtime = switchhookstyle = switchhookarg = 0;
31037 47171 switch_hooked = false;
31038
2/2
✓ Branch 0 taken 47170 times.
✓ Branch 1 taken 1 times.
47171 if(switching_object)
31039 1 switching_object->switch_hooked = false;
31040 47171 switching_object = NULL;
31041 47171 hooked_combopos = -1;
31042 47171 switchhook_cost_item = -1;
31043 47171 hooked_layerbits = 0;
31044
2/2
✓ Branch 0 taken 330197 times.
✓ Branch 1 taken 47171 times.
377368 for(auto q = 0; q < 7; ++q)
31045 330197 hooked_undercombos[q] = -1;
31046 47171 Lwpns.del(Lwpns.idFirst(wHSHandle));
31047 47171 Lwpns.del(Lwpns.idFirst(wHookshot));
31048 47171 chainlinks.clear();
31049
2/2
✓ Branch 0 taken 2474 times.
✓ Branch 1 taken 44697 times.
47171 int32_t index=directItem>-1 ? directItem : current_item_id(hs_switcher ? itype_switchhook : itype_hookshot);
31050 47171 hs_switcher = false;
31051
31052
2/2
✓ Branch 0 taken 39662 times.
✓ Branch 1 taken 7509 times.
47171 if(index>=0)
31053 {
31054 7509 stop_sfx(itemsbuf[index].usesound);
31055 7509 }
31056
31057 47171 hs_xdist=0;
31058 47171 hs_ydist=0;
31059 47171 }
31060
31061
31062 4378128 bool HeroClass::can_deploy_ladder()
31063 {
31064
2/2
✓ Branch 0 taken 1614115 times.
✓ Branch 1 taken 2764013 times.
6733510 bool ladderallowed = ((!get_bit(quest_rules,qr_LADDERANYWHERE) && tmpscr->flags&fLADDER) || isdungeon()
31065
4/4
✓ Branch 0 taken 1401019 times.
✓ Branch 1 taken 2355382 times.
✓ Branch 2 taken 547057 times.
✓ Branch 3 taken 1808325 times.
2764013 || (get_bit(quest_rules,qr_LADDERANYWHERE) && !(tmpscr->flags&fLADDER)));
31066
8/10
✓ Branch 0 taken 1715915 times.
✓ Branch 1 taken 3654601 times.
✓ Branch 2 taken 1345466 times.
✓ Branch 3 taken 370449 times.
✓ Branch 4 taken 1345397 times.
✓ Branch 5 taken 69 times.
✓ Branch 6 taken 1345397 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1345397 times.
6715913 return (current_item_id(itype_ladder)>-1 && ladderallowed && !ilswim && z==0 && fakez==0 &&
31067
2/2
✓ Branch 0 taken 1324717 times.
✓ Branch 1 taken 20680 times.
1345397 (!isSideViewHero() || on_sideview_solid_oldpos(x,y,old_x,old_y)));
31068 }
31069
31070 5604470 void HeroClass::reset_ladder()
31071 {
31072 5604470 ladderx=laddery=0;
31073 5604470 }
31074
31075 bool is_conveyor(int32_t type);
31076 int32_t get_conveyor(int32_t x, int32_t y);
31077
31078 6419565 void HeroClass::check_conveyor()
31079 {
31080 6419565 ++newconveyorclk;
31081
1/2
✓ Branch 0 taken 6419565 times.
✗ Branch 1 not taken.
6419565 if (newconveyorclk < 0) newconveyorclk = 0;
31082
31083
14/18
✓ Branch 0 taken 6419565 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6419565 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6418925 times.
✓ Branch 5 taken 640 times.
✓ Branch 6 taken 6418925 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6418925 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6416350 times.
✓ Branch 11 taken 2575 times.
✓ Branch 12 taken 6415728 times.
✓ Branch 13 taken 622 times.
✓ Branch 14 taken 6412095 times.
✓ Branch 15 taken 3633 times.
✓ Branch 16 taken 6412095 times.
✓ Branch 17 taken 3633 times.
6419565 if(action==casting||action==sideswimcasting||action==drowning || action==sidedrowning||action==lavadrowning||inlikelike||pull_hero||((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)))
31084 {
31085 7470 is_conveyor_stunned = 0;
31086 7470 return;
31087 }
31088
31089 6412095 WalkflagInfo info;
31090 int32_t xoff,yoff;
31091 6412095 zfix deltax(0), deltay(0);
31092 6412095 int32_t cmbid = get_conveyor(x+7,y+(bigHitbox?8:12));
31093
2/2
✓ Branch 0 taken 2133093 times.
✓ Branch 1 taken 4279002 times.
6412095 if(cmbid < 0)
31094 {
31095
2/2
✓ Branch 0 taken 4278291 times.
✓ Branch 1 taken 711 times.
4279002 if (conveyclk <= 0) is_on_conveyor=false;
31096 4279002 return;
31097 }
31098 2133093 newcombo const* cmb = &combobuf[cmbid];
31099 2133093 auto pos = COMBOPOS(x+7,y+(bigHitbox?8:12));
31100 2133093 bool custom_spd = (cmb->usrflags&cflag2);
31101
3/4
✓ Branch 0 taken 2132318 times.
✓ Branch 1 taken 775 times.
✓ Branch 2 taken 2132318 times.
✗ Branch 3 not taken.
2133093 if(custom_spd || conveyclk<=0) //!DIMITODO: let player be on multiple conveyors at once
31102 {
31103 2133093 int32_t ctype=cmb->type;
31104
3/4
✓ Branch 0 taken 775 times.
✓ Branch 1 taken 2132318 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 775 times.
2133093 auto rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
31105
3/4
✓ Branch 0 taken 775 times.
✓ Branch 1 taken 2132318 times.
✓ Branch 2 taken 775 times.
✗ Branch 3 not taken.
2133093 if(custom_spd && (newconveyorclk % rate)) return;
31106
3/4
✓ Branch 0 taken 555 times.
✓ Branch 1 taken 2132538 times.
✓ Branch 2 taken 555 times.
✗ Branch 3 not taken.
2133093 if((cmb->usrflags&cflag5) && HasHeavyBoots())
31107 return;
31108 2133093 is_on_conveyor=false;
31109 2133093 is_conveyor_stunned=0;
31110
31111 2133093 deltax=combo_class_buf[ctype].conveyor_x_speed;
31112 2133093 deltay=combo_class_buf[ctype].conveyor_y_speed;
31113
31114
3/4
✓ Branch 0 taken 1735 times.
✓ Branch 1 taken 2131358 times.
✓ Branch 2 taken 1735 times.
✗ Branch 3 not taken.
2133093 if (is_conveyor(ctype) && custom_spd)
31115 {
31116 deltax = zslongToFix(cmb->attributes[0]);
31117 deltay = zslongToFix(cmb->attributes[1]);
31118 }
31119
31120
8/8
✓ Branch 0 taken 2132308 times.
✓ Branch 1 taken 785 times.
✓ Branch 2 taken 2131358 times.
✓ Branch 3 taken 950 times.
✓ Branch 4 taken 87444 times.
✓ Branch 5 taken 2043914 times.
✓ Branch 6 taken 42801 times.
✓ Branch 7 taken 44643 times.
2133093 if((deltax==0&&deltay==0)&&(isSideViewHero() && on_sideview_solid_oldpos(x,y,old_x,old_y)))
31121 {
31122 44643 cmbid = MAPCOMBO(x+8,y+16);
31123 44643 cmb = &combobuf[cmbid];
31124 44643 custom_spd = cmb->usrflags&cflag2;
31125 44643 ctype=(cmb->type);
31126
3/4
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 43835 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 808 times.
44643 rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
31127 44643 deltax=combo_class_buf[ctype].conveyor_x_speed;
31128 44643 deltay=combo_class_buf[ctype].conveyor_y_speed;
31129
2/4
✓ Branch 0 taken 44643 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44643 times.
✗ Branch 3 not taken.
44643 if ((deltax != 0 || deltay != 0) && custom_spd)
31130 {
31131 deltax = zslongToFix(cmb->attributes[0]);
31132 deltay = zslongToFix(cmb->attributes[1]);
31133 }
31134 44643 }
31135
31136
4/4
✓ Branch 0 taken 2132308 times.
✓ Branch 1 taken 785 times.
✓ Branch 2 taken 950 times.
✓ Branch 3 taken 2131358 times.
2133093 if(deltax!=0||deltay!=0)
31137 {
31138 1735 is_on_conveyor=true;
31139 1735 }
31140 2131358 else return;
31141
31142
1/2
✓ Branch 0 taken 1735 times.
✗ Branch 1 not taken.
1735 bool forcewalk = (cmb->usrflags&cflag6) && get_bit(quest_rules,qr_NEW_HERO_MOVEMENT2);
31143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1735 times.
1735 if(forcewalk)
31144 {
31145 is_conveyor_stunned = rate;
31146 if(cmb->usrflags&cflag3)
31147 {
31148 if(abs(deltax) > abs(deltay))
31149 dir = (deltax > 0) ? right : left;
31150 else dir = (deltay > 0) ? down : up;
31151 }
31152 convey_forcex = deltax;
31153 convey_forcey = deltay;
31154 }
31155 else
31156 {
31157 1735 bool movedx = false, movedy = false;
31158
1/2
✓ Branch 0 taken 1735 times.
✗ Branch 1 not taken.
1735 if(cmb->usrflags&cflag4) //Smart corners
31159 {
31160 if(deltay<0)
31161 {
31162 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
31163 execute(info);
31164
31165 if(!info.isUnwalkable())
31166 {
31167 movedy = true;
31168 zfix step(0);
31169
31170 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
31171 {
31172 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
31173 {
31174 yoff=int32_t(y-step)&7;
31175
31176 if(!yoff) break;
31177
31178 step++;
31179 }
31180 }
31181 else
31182 {
31183 step=abs(deltay);
31184 }
31185
31186 y=y-step;
31187 hs_starty-=step.getInt();
31188
31189 for(int32_t j=0; j<chainlinks.Count(); j++)
31190 {
31191 chainlinks.spr(j)->y-=step;
31192 }
31193
31194 if(Lwpns.idFirst(wHookshot)>-1)
31195 {
31196 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
31197 }
31198
31199 if(Lwpns.idFirst(wHSHandle)>-1)
31200 {
31201 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
31202 }
31203 }
31204 }
31205 else if(deltay>0)
31206 {
31207 info = walkflag(x,y+15+2,2,down);
31208 execute(info);
31209
31210 if(!info.isUnwalkable())
31211 {
31212 movedy = true;
31213 zfix step(0);
31214
31215 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
31216 {
31217 while(step<abs(deltay))
31218 {
31219 yoff=int32_t(y+step)&7;
31220
31221 if(!yoff) break;
31222
31223 step++;
31224 }
31225 }
31226 else
31227 {
31228 step=abs(deltay);
31229 }
31230
31231 y=y+step;
31232 hs_starty+=step.getInt();
31233
31234 for(int32_t j=0; j<chainlinks.Count(); j++)
31235 {
31236 chainlinks.spr(j)->y+=step;
31237 }
31238
31239 if(Lwpns.idFirst(wHookshot)>-1)
31240 {
31241 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
31242 }
31243
31244 if(Lwpns.idFirst(wHSHandle)>-1)
31245 {
31246 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
31247 }
31248 }
31249 }
31250
31251 if(deltax<0)
31252 {
31253 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
31254 execute(info);
31255
31256 if(!info.isUnwalkable())
31257 {
31258 movedx = true;
31259 zfix step(0);
31260
31261 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
31262 {
31263 while(step<abs(deltax))
31264 {
31265 xoff=int32_t(x-step)&7;
31266
31267 if(!xoff) break;
31268
31269 step++;
31270 }
31271 }
31272 else
31273 {
31274 step=abs(deltax);
31275 }
31276
31277 x=x-step;
31278 hs_startx-=step.getInt();
31279
31280 for(int32_t j=0; j<chainlinks.Count(); j++)
31281 {
31282 chainlinks.spr(j)->x-=step;
31283 }
31284
31285 if(Lwpns.idFirst(wHookshot)>-1)
31286 {
31287 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
31288 }
31289
31290 if(Lwpns.idFirst(wHSHandle)>-1)
31291 {
31292 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
31293 }
31294 }
31295 }
31296 else if(deltax>0)
31297 {
31298 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
31299 execute(info);
31300
31301 if(!info.isUnwalkable())
31302 {
31303 movedx = true;
31304 zfix step(0);
31305
31306 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
31307 {
31308 while(step<abs(deltax))
31309 {
31310 xoff=int32_t(x+step)&7;
31311
31312 if(!xoff) break;
31313
31314 step++;
31315 }
31316 }
31317 else
31318 {
31319 step=abs(deltax);
31320 }
31321
31322 x=x+step;
31323 hs_startx+=step.getInt();
31324
31325 for(int32_t j=0; j<chainlinks.Count(); j++)
31326 {
31327 chainlinks.spr(j)->x+=step;
31328 }
31329
31330 if(Lwpns.idFirst(wHookshot)>-1)
31331 {
31332 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
31333 }
31334
31335 if(Lwpns.idFirst(wHSHandle)>-1)
31336 {
31337 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
31338 }
31339 }
31340 }
31341 if(deltax && !movedx)
31342 y = COMBOY(pos);
31343 if(deltay && !movedy)
31344 x = COMBOX(pos);
31345 }
31346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1735 times.
1735 if(!movedy)
31347 {
31348
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 1525 times.
1735 if(deltay<0)
31349 {
31350 210 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
31351 210 execute(info);
31352
31353
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 184 times.
210 if(!info.isUnwalkable())
31354 {
31355 184 movedy = true;
31356 184 zfix step(0);
31357
31358
10/12
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 118 times.
✓ Branch 4 taken 11 times.
✓ Branch 5 taken 55 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 6 times.
184 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
31359 {
31360
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 11 times.
16 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
31361 {
31362 11 yoff=int32_t(y-step)&7;
31363
31364
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
11 if(!yoff) break;
31365
31366 10 step++;
31367 }
31368 6 }
31369 else
31370 {
31371 178 step=abs(deltay);
31372 }
31373
31374 184 y=y-step;
31375 184 hs_starty-=step.getInt();
31376
31377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 184 times.
184 for(int32_t j=0; j<chainlinks.Count(); j++)
31378 {
31379 chainlinks.spr(j)->y-=step;
31380 }
31381
31382
1/2
✓ Branch 0 taken 184 times.
✗ Branch 1 not taken.
184 if(Lwpns.idFirst(wHookshot)>-1)
31383 {
31384 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
31385 }
31386
31387
1/2
✓ Branch 0 taken 184 times.
✗ Branch 1 not taken.
184 if(Lwpns.idFirst(wHSHandle)>-1)
31388 {
31389 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
31390 }
31391 184 }
31392 26 else checkdamagecombos(x,y+8-(bigHitbox ? 8 : 0)-2);
31393 210 }
31394
2/2
✓ Branch 0 taken 785 times.
✓ Branch 1 taken 740 times.
1525 else if(deltay>0)
31395 {
31396 740 info = walkflag(x,y+15+2,2,down);
31397 740 execute(info);
31398
31399
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 488 times.
740 if(!info.isUnwalkable())
31400 {
31401 488 movedy = true;
31402 488 zfix step(0);
31403
31404
9/12
✓ Branch 0 taken 338 times.
✓ Branch 1 taken 150 times.
✓ Branch 2 taken 167 times.
✓ Branch 3 taken 321 times.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 105 times.
✓ Branch 6 taken 62 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 62 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 62 times.
488 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
31405 {
31406
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 104 times.
144 while(step<abs(deltay))
31407 {
31408 104 yoff=int32_t(y+step)&7;
31409
31410
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 82 times.
104 if(!yoff) break;
31411
31412 82 step++;
31413 }
31414 62 }
31415 else
31416 {
31417 426 step=abs(deltay);
31418 }
31419
31420 488 y=y+step;
31421 488 hs_starty+=step.getInt();
31422
31423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 488 times.
488 for(int32_t j=0; j<chainlinks.Count(); j++)
31424 {
31425 chainlinks.spr(j)->y+=step;
31426 }
31427
31428
1/2
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
488 if(Lwpns.idFirst(wHookshot)>-1)
31429 {
31430 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
31431 }
31432
31433
1/2
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
488 if(Lwpns.idFirst(wHSHandle)>-1)
31434 {
31435 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
31436 }
31437 488 }
31438 252 else checkdamagecombos(x,y+15);
31439 740 }
31440 1735 }
31441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1735 times.
1735 if(!movedx)
31442 {
31443
2/2
✓ Branch 0 taken 518 times.
✓ Branch 1 taken 1217 times.
1735 if(deltax<0)
31444 {
31445 518 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
31446 518 execute(info);
31447
31448
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 352 times.
518 if(!info.isUnwalkable())
31449 {
31450 352 movedx = true;
31451 352 zfix step(0);
31452
31453
9/12
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 70 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 296 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 38 times.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 18 times.
352 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
31454 {
31455
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 32 times.
45 while(step<abs(deltax))
31456 {
31457 32 xoff=int32_t(x-step)&7;
31458
31459
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 5 times.
32 if(!xoff) break;
31460
31461 27 step++;
31462 }
31463 18 }
31464 else
31465 {
31466 334 step=abs(deltax);
31467 }
31468
31469 352 x=x-step;
31470 352 hs_startx-=step.getInt();
31471
31472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 352 times.
352 for(int32_t j=0; j<chainlinks.Count(); j++)
31473 {
31474 chainlinks.spr(j)->x-=step;
31475 }
31476
31477
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 if(Lwpns.idFirst(wHookshot)>-1)
31478 {
31479 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
31480 }
31481
31482
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 if(Lwpns.idFirst(wHSHandle)>-1)
31483 {
31484 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
31485 }
31486 352 }
31487 166 else checkdamagecombos(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0));
31488 518 }
31489
2/2
✓ Branch 0 taken 950 times.
✓ Branch 1 taken 267 times.
1217 else if(deltax>0)
31490 {
31491 267 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
31492 267 execute(info);
31493
31494
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 264 times.
267 if(!info.isUnwalkable())
31495 {
31496 264 movedx = true;
31497 264 zfix step(0);
31498
31499
9/12
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 208 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 31 times.
✓ Branch 6 taken 25 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 25 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 25 times.
264 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
31500 {
31501
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 47 times.
67 while(step<abs(deltax))
31502 {
31503 47 xoff=int32_t(x+step)&7;
31504
31505
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 5 times.
47 if(!xoff) break;
31506
31507 42 step++;
31508 }
31509 25 }
31510 else
31511 {
31512 239 step=abs(deltax);
31513 }
31514
31515 264 x=x+step;
31516 264 hs_startx+=step.getInt();
31517
31518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 for(int32_t j=0; j<chainlinks.Count(); j++)
31519 {
31520 chainlinks.spr(j)->x+=step;
31521 }
31522
31523
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(Lwpns.idFirst(wHookshot)>-1)
31524 {
31525 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
31526 }
31527
31528
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(Lwpns.idFirst(wHSHandle)>-1)
31529 {
31530 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
31531 }
31532 264 }
31533 3 else checkdamagecombos(x+15+2,y+8-(bigHitbox ? 8 : 0));
31534 267 }
31535 1735 }
31536
4/4
✓ Branch 0 taken 1119 times.
✓ Branch 1 taken 616 times.
✓ Branch 2 taken 672 times.
✓ Branch 3 taken 447 times.
1735 if(movedx || movedy)
31537 {
31538
1/2
✓ Branch 0 taken 1288 times.
✗ Branch 1 not taken.
1288 if(cmb->usrflags&cflag1)
31539 is_conveyor_stunned = rate;
31540
1/2
✓ Branch 0 taken 1288 times.
✗ Branch 1 not taken.
1288 if(cmb->usrflags&cflag3)
31541 {
31542 if(abs(deltax) > abs(deltay))
31543 dir = (deltax > 0) ? right : left;
31544 else dir = (deltay > 0) ? down : up;
31545 }
31546 1288 }
31547 }
31548 1735 }
31549 6419565 }
31550
31551 void HeroClass::setDivineProtectionShieldClk(int32_t newclk)
31552 {
31553 DivineProtectionShieldClk=newclk;
31554
31555 if(decorations.idCount(dDIVINEPROTECTIONSHIELD)==0)
31556 {
31557 decoration *dec;
31558 decorations.add(new dDivineProtectionShield(HeroX(), HeroY(), dDIVINEPROTECTIONSHIELD, 0));
31559 decorations.spr(decorations.Count()-1)->misc=0;
31560 decorations.add(new dDivineProtectionShield(HeroX(), HeroY(), dDIVINEPROTECTIONSHIELD, 0));
31561 dec=(decoration *)decorations.spr(decorations.Count()-1);
31562 decorations.spr(decorations.Count()-1)->misc=1;
31563 }
31564 }
31565
31566 13489 int32_t HeroClass::getDivineProtectionShieldClk()
31567 {
31568 13489 return DivineProtectionShieldClk;
31569 }
31570
31571 21 int32_t HeroClass::getHoverClk()
31572 {
31573 21 return hoverclk;
31574 }
31575
31576 7641300 int32_t HeroClass::getHoldClk()
31577 {
31578 7641300 return holdclk;
31579 }
31580
31581 4275134 int32_t HeroClass::getLastLensID(){
31582 4275134 return last_lens_id;
31583 }
31584
31585 209 void HeroClass::setLastLensID(int32_t p_item){
31586 209 last_lens_id = p_item;
31587 209 }
31588
31589 53450328 bool HeroClass::getOnSideviewLadder()
31590 {
31591 53450328 return on_sideview_ladder;
31592 }
31593
31594 95 void HeroClass::setOnSideviewLadder(bool val)
31595 {
31596
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 9 times.
95 if(val)
31597 {
31598 9 fall = fakefall = hoverclk = jumping = 0;
31599 9 hoverflags = 0;
31600 9 inair = false;
31601 9 }
31602 95 on_sideview_ladder = val;
31603 95 }
31604
31605 1914154 bool HeroClass::canSideviewLadder(bool down)
31606 {
31607
2/2
✓ Branch 0 taken 1876943 times.
✓ Branch 1 taken 37211 times.
1914154 if(!isSideViewHero()) return false;
31608
2/2
✓ Branch 0 taken 24005 times.
✓ Branch 1 taken 13206 times.
37211 if(jumping < 0) return false;
31609
3/4
✓ Branch 0 taken 10405 times.
✓ Branch 1 taken 13600 times.
✓ Branch 2 taken 10405 times.
✗ Branch 3 not taken.
24005 if(down && get_bit(quest_rules, qr_DOWN_DOESNT_GRAB_LADDERS))
31610 {
31611 bool onSolid = on_sideview_solid_oldpos(x,y,old_x,old_y,true);
31612 return ((isSVLadder(x+4,y+16) && (!isSVLadder(x+4,y)||onSolid)) || (isSVLadder(x+12,y+16) && (!isSVLadder(x+12,y)||onSolid)));
31613 }
31614 //Are you presently able to climb a sideview ladder?
31615 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
31616 //y+0 checks your top-half for large hitbox; y+8 for small
31617 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
31618 //y+16 check is for going down onto a ladder you are standing on.
31619
2/2
✓ Branch 0 taken 23588 times.
✓ Branch 1 taken 417 times.
47432 return (isSVLadder(x+4,y+(bigHitbox?0:8)) || isSVLadder(x+12,y+(bigHitbox?0:8)))
31620
4/4
✓ Branch 0 taken 23427 times.
✓ Branch 1 taken 161 times.
✓ Branch 2 taken 23382 times.
✓ Branch 3 taken 45 times.
23588 || isSVLadder(x+4,y+15) || isSVLadder(x+12,y+15)
31621
5/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 23360 times.
✓ Branch 2 taken 12955 times.
✓ Branch 3 taken 10405 times.
✓ Branch 4 taken 10405 times.
✗ Branch 5 not taken.
33787 || (down && (isSVLadder(x+4,y+16) || isSVLadder(x+12,y+16)));
31622 1914154 }
31623
31624 bool HeroClass::canSideviewLadderRemote(int32_t wx, int32_t wy, bool down)
31625 {
31626 if(!isSideViewHero()) return false;
31627 if(jumping < 0) return false;
31628 if(down && get_bit(quest_rules, qr_DOWN_DOESNT_GRAB_LADDERS))
31629 {
31630 bool onSolid = on_sideview_solid_oldpos(x,y,old_x,old_y,true);
31631 return ((isSVLadder(wx+4,wy+16) && (!isSVLadder(wx+4,wy)||onSolid)) || (isSVLadder(wx+12,wy+16) && (!isSVLadder(wx+12,wy)||onSolid)));
31632 }
31633 //Are you presently able to climb a sideview ladder?
31634 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
31635 //y+0 checks your top-half for large hitbox; y+8 for small
31636 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
31637 //y+16 check is for going down onto a ladder you are standing on.
31638 return (isSVLadder(wx+4,wy+(bigHitbox?0:8)) || isSVLadder(wx+12,wy+(bigHitbox?0:8)))
31639 || isSVLadder(wx+4,wy+15) || isSVLadder(wx+12,wy+15)
31640 || (down && (isSVLadder(wx+4,wy+16) || isSVLadder(wx+12,wy+16)));
31641 }
31642
31643 3964184 void HeroClass::execute(HeroClass::WalkflagInfo info)
31644 {
31645 3964184 int32_t flags = info.getFlags();
31646
31647
2/2
✓ Branch 0 taken 648 times.
✓ Branch 1 taken 3963536 times.
3964184 if(flags & WalkflagInfo::CLEARILSWIM)
31648 648 ilswim =false;
31649
2/2
✓ Branch 0 taken 3962740 times.
✓ Branch 1 taken 796 times.
3963536 else if(flags & WalkflagInfo::SETILSWIM)
31650 796 ilswim = true;
31651
31652
1/2
✓ Branch 0 taken 3964184 times.
✗ Branch 1 not taken.
3964184 if(flags & WalkflagInfo::CLEARCHARGEATTACK)
31653 {
31654 charging = 0;
31655 attackclk = 0;
31656 }
31657
31658
1/2
✓ Branch 0 taken 3964184 times.
✗ Branch 1 not taken.
3964184 if(flags & WalkflagInfo::SETDIR)
31659 {
31660 dir = info.getDir();
31661 }
31662
31663
2/2
✓ Branch 0 taken 3963607 times.
✓ Branch 1 taken 577 times.
3964184 if(flags & WalkflagInfo::SETHOPCLK)
31664 {
31665 577 hopclk = info.getHopClk();
31666 577 }
31667
31668
2/2
✓ Branch 0 taken 3963686 times.
✓ Branch 1 taken 498 times.
3964184 if(flags & WalkflagInfo::SETHOPDIR)
31669 {
31670 498 hopdir = info.getHopDir();
31671 498 }
31672
31673 3964184 }
31674
31675 8570700 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator ||(HeroClass::WalkflagInfo other)
31676 {
31677 8570700 HeroClass::WalkflagInfo ret;
31678 8570700 ret.newhopclk = newhopclk;
31679 8570700 ret.newdir = newdir;
31680
2/2
✓ Branch 0 taken 7101738 times.
✓ Branch 1 taken 1468962 times.
8570700 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
31681
31682 8570700 int32_t flags1 = (flags & ~UNWALKABLE) & (other.flags & ~UNWALKABLE);
31683 8570700 int32_t flags2 = (flags & UNWALKABLE) | (other.flags & UNWALKABLE);
31684 8570700 ret.flags = flags1 | flags2;
31685 8570700 return ret;
31686 }
31687
31688 48864 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator &&(HeroClass::WalkflagInfo other)
31689 {
31690 48864 HeroClass::WalkflagInfo ret;
31691 48864 ret.newhopclk = newhopclk;
31692 48864 ret.newdir = newdir;
31693
1/2
✓ Branch 0 taken 48864 times.
✗ Branch 1 not taken.
48864 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
31694
31695 48864 ret.flags = flags & other.flags;
31696 48864 return ret;
31697 }
31698
31699 48864 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator !()
31700 {
31701 48864 HeroClass::WalkflagInfo ret;
31702 48864 ret.newhopclk = newhopclk;
31703 48864 ret.newdir = newdir;
31704 48864 ret.newhopdir = newhopdir;
31705
31706 48864 ret.flags = flags ^ UNWALKABLE;
31707 48864 return ret;
31708 }
31709
31710 void HeroClass::explode(int32_t type)
31711 {
31712 static int32_t tempx, tempy;
31713 static byte herotilebuf[256];
31714 int32_t ltile=0;
31715 int32_t lflip=0;
31716 bool shieldModify=true;
31717 unpack_tile(newtilebuf, tile, flip, true);
31718 memcpy(herotilebuf, unpackbuf, 256);
31719 tempx=Hero.getX();
31720 tempy=Hero.getY();
31721 for(int32_t i=0; i<16; ++i)
31722 {
31723 for(int32_t j=0; j<16; ++j)
31724 {
31725 if(herotilebuf[i*16+j])
31726 {
31727 if(type==0) // Twilight
31728 {
31729 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 0, 0, (zc_oldrand()%8)+i*4));
31730 int32_t k=particles.Count()-1;
31731 particle *p = (particles.at(k));
31732 p->step=3;
31733 }
31734 else if(type ==1) // Sands of Hours
31735 {
31736 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 1, 2, (zc_oldrand()%16)+i*2));
31737 int32_t k=particles.Count()-1;
31738 particle *p = (particles.at(k));
31739 p->step=4;
31740
31741 if(zc_oldrand()%10 < 2)
31742 {
31743 p->color=1;
31744 p->cset=0;
31745 }
31746 }
31747 else
31748 {
31749 particles.add(new pDivineEscapeDust(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 6, herotilebuf[i*16+j], zc_oldrand()%96));
31750
31751 int32_t k=particles.Count()-1;
31752 particle *p = (particles.at(k));
31753 p->angular=true;
31754 p->angle=zc_oldrand();
31755 p->step=(((double)j)/8);
31756 p->yofs=Hero.getYOfs();
31757 }
31758 }
31759 }
31760 }
31761 }
31762
31763 984 void HeroClass::SetSwim()
31764 {
31765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 984 times.
984 if (CanSideSwim())
31766 {
31767 if (action != sideswimattacking && action != attacking) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
31768 else {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
31769 if (get_bit(quest_rules,qr_SIDESWIMDIR) && spins <= 0 && dir != left && dir != right) dir = sideswimdir;
31770 }
31771 984 else {action=swimming; FFCore.setHeroAction(swimming);}
31772 984 }
31773
31774 60436 void HeroClass::SetAttack()
31775 {
31776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60436 times.
60436 if (IsSideSwim()) {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
31777 60436 else {action=attacking; FFCore.setHeroAction(attacking);}
31778 60436 }
31779
31780 53158302 bool HeroClass::IsSideSwim()
31781 {
31782
6/12
✓ Branch 0 taken 53158302 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53158302 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 53158302 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 53158302 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 53158302 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 53158302 times.
53158302 return (action==sideswimming || action==sideswimhit || action == sideswimattacking || action == sidewaterhold1 || action == sidewaterhold2 || action == sideswimcasting || action == sideswimfreeze);
31783 }
31784
31785 1533026 bool HeroClass::CanSideSwim()
31786 {
31787
1/2
✓ Branch 0 taken 1533026 times.
✗ Branch 1 not taken.
1533026 return (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM));
31788 }
31789
31790 5075613 int32_t HeroClass::getTileModifier()
31791 {
31792 5075613 return item_tile_mod() + bunny_tile_mod();
31793 }
31794 void HeroClass::setImmortal(int32_t nimmortal)
31795 {
31796 immortal = nimmortal;
31797 }
31798 void HeroClass::kill(bool bypassFairy)
31799 {
31800 dying_flags = DYING_FORCED | (bypassFairy ? DYING_NOREV : 0);
31801 }
31802 12880431 bool HeroClass::sideview_mode() const
31803 {
31804
3/4
✓ Branch 0 taken 548487 times.
✓ Branch 1 taken 12331944 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 548487 times.
12880431 return isSideViewHero() && (moveflags & FLAG_OBEYS_GRAV) && !toogam;
31805 }
31806 9441 bool HeroClass::is_unpushable() const
31807 {
31808 9441 return toogam;
31809 }
31810